maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r985676 - /maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
Date Sun, 15 Aug 2010 13:50:41 GMT
Author: bentmann
Date: Sun Aug 15 13:50:41 2010
New Revision: 985676

URL: http://svn.apache.org/viewvc?rev=985676&view=rev
Log:
o Added detection of Maven version to ease execution of individual ITs via -Dtest=

Modified:
    maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java

Modified: maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java?rev=985676&r1=985675&r2=985676&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
(original)
+++ maven/core-integration-testing/trunk/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
Sun Aug 15 13:50:41 2010
@@ -133,11 +133,33 @@ public abstract class AbstractMavenInteg
     {
         if ( mavenVersion == null )
         {
-            String v = System.getProperty( "maven.version" );
+            String version = System.getProperty( "maven.version", "" );
+
+            if ( version.length() <= 0 || version.startsWith( "${" ) )
+            {
+                try
+                {
+                    Verifier verifier = new Verifier( "" );
+                    try
+                    {
+                        version = verifier.getMavenVersion();
+                        System.setProperty( "maven.version", version );
+                    }
+                    finally
+                    {
+                        verifier.resetStreams();
+                    }
+                }
+                catch ( VerificationException e )
+                {
+                    e.printStackTrace();
+                }
+            }
+
             // NOTE: If the version looks like "${...}" it has been configured from an undefined
expression
-            if ( v != null && v.length() > 0 && !v.startsWith( "${" )
)
+            if ( version != null && version.length() > 0 && !version.startsWith(
"${" ) )
             {
-                mavenVersion = new DefaultArtifactVersion( v );
+                mavenVersion = new DefaultArtifactVersion( version );
             }
         }
         return mavenVersion;



Mime
View raw message