maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r727762 - in /maven/components/branches/maven-2.1.x/maven-core: pom.xml src/main/java/org/apache/maven/cli/MavenCli.java src/main/resources/org/apache/maven/messages/build.properties
Date Thu, 18 Dec 2008 16:59:57 GMT
Author: brett
Date: Thu Dec 18 08:59:57 2008
New Revision: 727762

URL: http://svn.apache.org/viewvc?rev=727762&view=rev
Log:
[MNG-1830] add build information

Added:
    maven/components/branches/maven-2.1.x/maven-core/src/main/resources/org/apache/maven/messages/build.properties
  (with props)
Modified:
    maven/components/branches/maven-2.1.x/maven-core/pom.xml
    maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java

Modified: maven/components/branches/maven-2.1.x/maven-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/pom.xml?rev=727762&r1=727761&r2=727762&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/pom.xml (original)
+++ maven/components/branches/maven-2.1.x/maven-core/pom.xml Thu Dec 18 08:59:57 2008
@@ -238,5 +238,34 @@
         </plugins>
       </build>
     </profile>
+    <profile>
+      <id>buildnumber</id>
+      <activation>
+        <file>
+          <exists>.svn</exists>
+        </file>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>buildnumber-maven-plugin</artifactId>
+            <version>1.0-beta-1</version>
+            <executions>
+              <execution>
+                <phase>generate-resources</phase>
+                <goals>
+                  <goal>create</goal>
+                </goals>
+              </execution>
+            </executions>
+            <configuration>
+              <doCheck>false</doCheck>
+              <doUpdate>false</doUpdate>
+            </configuration>
+          </plugin>        
+        </plugins>
+      </build>
+    </profile>
   </profiles>
 </project>

Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java?rev=727762&r1=727761&r2=727762&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
(original)
+++ maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
Thu Dec 18 08:59:57 2008
@@ -54,6 +54,7 @@
 import org.codehaus.plexus.embed.Embedder;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.LoggerManager;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.Os;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -575,45 +576,58 @@
 
     private static void showVersion()
     {
-        InputStream resourceAsStream;
+        Properties properties = new Properties();
+        String timestamp = null;
+        String rev = null;
+        String version = null;
+
+        InputStream resourceAsStream = null;
         try
         {
-            Properties properties = new Properties();
-            resourceAsStream = MavenCli.class.getClassLoader().getResourceAsStream(
-                "META-INF/maven/org.apache.maven/maven-core/pom.properties" );
+            resourceAsStream = MavenCli.class.getClassLoader().getResourceAsStream( "org/apache/maven/messages/build.properties"
);
 
             if ( resourceAsStream != null )
             {
                 properties.load( resourceAsStream );
 
-                if( properties.getProperty( "builtOn" ) != null )
-                {
-                    System.out.println( "Maven version: " + properties.getProperty( "version",
"unknown" )
-                        + " built on " + properties.getProperty( "builtOn" ) );
-                }
-                else
-                {
-                    System.out.println( "Maven version: " + properties.getProperty( "version",
"unknown" ) );
-                }
+                timestamp = reduce( properties.getProperty( "timestamp" ) );
+                version = reduce( properties.getProperty( "version" ) );
+                rev = reduce( properties.getProperty( "buildNumber" ) );
             }
-            else
-            {
-                System.out.println( "Maven version: unknown" );
-            }
-
-            System.out.println( "Java version: " + System.getProperty( "java.version", "<unknown
java version>" ) );
-
-            System.out.println( "Default locale: " + Locale.getDefault() + ", platform encoding:
"
-                                + System.getProperty( "file.encoding", "<unknown encoding>"
) );
-
-            System.out.println( "OS name: \"" + Os.OS_NAME + "\" version: \"" + Os.OS_VERSION
+
-                                "\" arch: \"" + Os.OS_ARCH + "\" family: \"" + Os.OS_FAMILY
+ "\"" );
-
         }
         catch ( IOException e )
         {
             System.err.println( "Unable determine version from JAR file: " + e.getMessage()
);
         }
+        finally
+        {
+            IOUtil.close( resourceAsStream );
+        }
+
+        String msg = "Apache Maven ";
+        msg += ( version != null ? version : "<version unknown>" );
+        if ( rev != null || timestamp != null )
+        {
+            msg += " (";
+            msg += ( rev != null ? "r" + rev : "" );
+            msg += ( timestamp != null ? ( rev != null ? "; " : "" ) + new java.util.Date(
Long.valueOf( timestamp ).longValue() ) : "" );
+            msg += ")";
+        }
+
+        System.out.println( msg );
+
+        System.out.println( "Java version: " + System.getProperty( "java.version", "<unknown
java version>" ) );
+
+        System.out.println( "Default locale: " + Locale.getDefault() + ", platform encoding:
"
+                            + System.getProperty( "file.encoding", "<unknown encoding>"
) );
+
+        System.out.println( "OS name: \"" + Os.OS_NAME + "\" version: \"" + Os.OS_VERSION
+
+                            "\" arch: \"" + Os.OS_ARCH + "\" family: \"" + Os.OS_FAMILY +
"\"" );
+    }
+
+    private static String reduce( String s )
+    {
+        return ( s != null ? ( s.startsWith( "${" ) && s.endsWith( "}" ) ? null :
s ) : null );
     }
 
     // ----------------------------------------------------------------------

Added: maven/components/branches/maven-2.1.x/maven-core/src/main/resources/org/apache/maven/messages/build.properties
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/resources/org/apache/maven/messages/build.properties?rev=727762&view=auto
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/src/main/resources/org/apache/maven/messages/build.properties
(added)
+++ maven/components/branches/maven-2.1.x/maven-core/src/main/resources/org/apache/maven/messages/build.properties
Thu Dec 18 08:59:57 2008
@@ -0,0 +1,3 @@
+buildNumber=${buildNumber}
+timestamp=${timestamp}
+version=${project.version}

Propchange: maven/components/branches/maven-2.1.x/maven-core/src/main/resources/org/apache/maven/messages/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message