1 package org.apache.maven.execution; 2 3 18 19 import org.apache.maven.artifact.versioning.ArtifactVersion; 20 import org.apache.maven.artifact.versioning.DefaultArtifactVersion; 21 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; 22 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; 23 import org.codehaus.plexus.util.IOUtil; 24 25 import java.io.IOException ; 26 import java.io.InputStream ; 27 import java.util.Properties ; 28 29 35 public class DefaultRuntimeInformation 36 implements RuntimeInformation, Initializable 37 { 38 private ArtifactVersion applicationVersion; 39 40 public ArtifactVersion getApplicationVersion() 41 { 42 return applicationVersion; 43 } 44 45 public void initialize() 46 throws InitializationException 47 { 48 InputStream resourceAsStream = null; 49 try 50 { 51 Properties properties = new Properties (); 52 resourceAsStream = getClass().getClassLoader().getResourceAsStream( 53 "META-INF/maven/org.apache.maven/maven-core/pom.properties" ); 54 properties.load( resourceAsStream ); 55 56 String property = properties.getProperty( "version" ); 57 if ( property == null ) 58 { 59 throw new InitializationException( "maven-core properties did not include the version" ); 60 } 61 62 applicationVersion = new DefaultArtifactVersion( property ); 63 } 64 catch ( IOException e ) 65 { 66 throw new InitializationException( "Unable to read properties file from maven-core", e ); 67 } 68 finally 69 { 70 IOUtil.close( resourceAsStream ); 71 } 72 } 73 } 74 | Popular Tags |