maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r980568 - in /maven/surefire/trunk: maven-failsafe-plugin/ maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-plugin/ maven-surefire-plu...
Date Thu, 29 Jul 2010 20:56:29 GMT
Author: krosenvold
Date: Thu Jul 29 20:56:29 2010
New Revision: 980568

URL: http://svn.apache.org/viewvc?rev=980568&view=rev
Log:
[SUREFIRE-617] Support @threadSafe in surefire

Modified:
    maven/surefire/trunk/maven-failsafe-plugin/pom.xml
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
    maven/surefire/trunk/maven-surefire-plugin/pom.xml
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/surefire/trunk/maven-surefire-report-plugin/pom.xml
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java

Modified: maven/surefire/trunk/maven-failsafe-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/pom.xml?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/pom.xml (original)
+++ maven/surefire/trunk/maven-failsafe-plugin/pom.xml Thu Jul 29 20:56:29 2010
@@ -141,7 +141,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
-        <version>2.5.1</version>
+        <version>2.6</version>
         <executions>
           <execution>
             <id>generated-helpmojo</id>
@@ -211,7 +211,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
-        <version>2.5.1</version>
+        <version>2.6</version>
       </plugin>
     </plugins>
   </reporting>

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
(original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
Thu Jul 29 20:56:29 2010
@@ -59,6 +59,7 @@ import org.codehaus.plexus.util.StringUt
  * @requiresDependencyResolution test
  * @goal integration-test
  * @phase integration-test
+ * @threadSafe
  */
 public class IntegrationTestMojo
     extends AbstractSurefireMojo
@@ -583,6 +584,9 @@ public class IntegrationTestMojo
      */
     private String encoding;
 
+    /** @parameter default-value="${session.parallel}" */
+    private Boolean parallelMavenExecution;
+
     /**
      * @component
      */
@@ -672,6 +676,7 @@ public class IntegrationTestMojo
             return false;
         }
 
+
         if ( !getTestClassesDirectory().exists() )
         {
             if ( getFailIfNoTests() != null && getFailIfNoTests().booleanValue()
)
@@ -682,23 +687,11 @@ public class IntegrationTestMojo
             return false;
         }
 
-        if ( !getWorkingDirectory().exists() )
-        {
-            if ( !getWorkingDirectory().mkdirs() )
-            {
-                throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory()
);
-            }
-        }
+        ensureWorkingDirectoryExists();
 
-        if ( !getWorkingDirectory().isDirectory() )
-        {
-            throw new MojoFailureException( "workingDirectory " + getWorkingDirectory() +
" exists and is not a directory" );
-        }
+        ensureParallelRunningCompatibility();
 
-        if ( getUseSystemClassLoader() != null && ForkConfiguration.FORK_NEVER.equals(
getForkMode() ) )
-        {
-            getLog().warn( "useSystemClassloader setting has no effect when not forking"
);
-        }
+        warnIfUselessUseSystemClassLoaderParameter();
 
         return true;
     }
@@ -1315,4 +1308,10 @@ public class IntegrationTestMojo
         // ignore
     }
 
+    public boolean isMavenParallel()
+    {
+        return parallelMavenExecution  != null && parallelMavenExecution.booleanValue();
+    }
+
+
 }

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
(original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
Thu Jul 29 20:56:29 2010
@@ -56,6 +56,7 @@ import org.codehaus.plexus.util.xml.pull
  * @requiresProject true
  * @goal verify
  * @phase verify
+ * @threadSafe
  */
 public class VerifyMojo
     extends AbstractMojo

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
Thu Jul 29 20:56:29 2010
@@ -108,7 +108,7 @@ public abstract class AbstractSurefireMo
         }
     }
 
-    private boolean isAnyConcurrencySelected()
+    protected boolean isAnyConcurrencySelected()
     {
         return this.getParallel() != null && this.getParallel().trim().length() >
0;
     }
@@ -188,6 +188,11 @@ public abstract class AbstractSurefireMo
         }
     }
 
+    protected boolean isForkModeNever()
+    {
+        return ForkConfiguration.FORK_NEVER.equals( getForkMode()); 
+    }
+
     protected SurefireBooter constructSurefireBooter()
         throws MojoExecutionException, MojoFailureException
     {
@@ -402,7 +407,7 @@ public abstract class AbstractSurefireMo
         if ( tc != null )
         {
             getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + tc );
-            if ( ForkConfiguration.FORK_NEVER.equals( getForkMode() ) )
+            if ( isForkModeNever() )
             {
                 setForkMode( ForkConfiguration.FORK_ONCE );
             }
@@ -760,4 +765,37 @@ public abstract class AbstractSurefireMo
         }
     }
 
+    protected void ensureWorkingDirectoryExists()
+        throws MojoFailureException
+    {
+        if ( !getWorkingDirectory().exists() )
+        {
+            if ( !getWorkingDirectory().mkdirs() )
+            {
+                throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory()
);
+            }
+        }
+
+        if ( !getWorkingDirectory().isDirectory() )
+        {
+            throw new MojoFailureException( "workingDirectory " + getWorkingDirectory() +
" exists and is not a directory" );
+        }
+    }
+
+    protected void ensureParallelRunningCompatibility()
+        throws MojoFailureException
+    {
+        if (isMavenParallel() && isForkModeNever())
+        {
+            throw new MojoFailureException( "parallel maven execution is not compatible with
surefire forkmode NEVER");
+        }
+    }
+
+    protected void warnIfUselessUseSystemClassLoaderParameter()
+    {
+        if ( getUseSystemClassLoader() != null && isForkModeNever() )
+        {
+            getLog().warn( "useSystemClassloader setting has no effect when not forking"
);
+        }
+    }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
Thu Jul 29 20:56:29 2010
@@ -247,4 +247,7 @@ public interface SurefireExecutionParame
     Boolean getFailIfNoTests();
 
     void setFailIfNoTests( Boolean failIfNoTests );
+
+    boolean isMavenParallel();
+
 }

Modified: maven/surefire/trunk/maven-surefire-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/pom.xml?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/pom.xml (original)
+++ maven/surefire/trunk/maven-surefire-plugin/pom.xml Thu Jul 29 20:56:29 2010
@@ -148,7 +148,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
-        <version>2.5.1</version>
+        <version>2.6</version>
         <executions>
           <execution>
             <id>generated-helpmojo</id>
@@ -172,7 +172,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
-        <version>2.5.1</version>
+        <version>2.6</version>
       </plugin>
     </plugins>
   </reporting>

Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
(original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Thu Jul 29 20:56:29 2010
@@ -48,6 +48,7 @@ import org.codehaus.plexus.util.StringUt
  * @requiresDependencyResolution test
  * @goal test
  * @phase test
+ * @threadSafe
  */
 public class SurefirePlugin
     extends AbstractSurefireMojo
@@ -549,6 +550,10 @@ public class SurefirePlugin
      */
     private String objectFactory;
 
+
+    /** @parameter default-value="${session.parallel}" */
+    private Boolean parallelMavenExecution;
+    
     /**
      * @component
      */
@@ -605,26 +610,14 @@ public class SurefirePlugin
                 throw new MojoFailureException( "No tests to run!" );
             }
             getLog().info( "No tests to run." );
-            return false;
+            return true;
         }
 
-        if ( !getWorkingDirectory().exists() )
-        {
-            if ( !getWorkingDirectory().mkdirs() )
-            {
-                throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory()
);
-            }
-        }
+        ensureWorkingDirectoryExists();
 
-        if ( !getWorkingDirectory().isDirectory() )
-        {
-            throw new MojoFailureException( "workingDirectory " + getWorkingDirectory() +
" exists and is not a directory" );
-        }
+        ensureParallelRunningCompatibility();
 
-        if ( getUseSystemClassLoader() != null && ForkConfiguration.FORK_NEVER.equals(
getForkMode() ) )
-        {
-            getLog().warn( "useSystemClassloader setting has no effect when not forking"
);
-        }
+        warnIfUselessUseSystemClassLoaderParameter();
 
         return true;
     }
@@ -646,6 +639,8 @@ public class SurefirePlugin
         return skipTests;
     }
 
+
+
     public void setSkipTests( boolean skipTests )
     {
         this.skipTests = skipTests;
@@ -1221,4 +1216,10 @@ public class SurefirePlugin
         this.toolchainManager = toolchainManager;
     }
 
+    public boolean isMavenParallel()
+    {
+        return parallelMavenExecution  != null && parallelMavenExecution.booleanValue();
+    }
+    
+
 }

Modified: maven/surefire/trunk/maven-surefire-report-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-report-plugin/pom.xml?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-report-plugin/pom.xml (original)
+++ maven/surefire/trunk/maven-surefire-report-plugin/pom.xml Thu Jul 29 20:56:29 2010
@@ -130,7 +130,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
-        <version>2.5.1</version>
+        <version>2.6</version>
         <executions>
           <execution>
             <id>generated-helpmojo</id>
@@ -155,7 +155,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
-        <version>2.5.1</version>
+        <version>2.6</version>
       </plugin>
     </plugins>
   </reporting>

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?rev=980568&r1=980567&r2=980568&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
(original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
Thu Jul 29 20:56:29 2010
@@ -237,7 +237,7 @@ public class SurefireBooter
     {
         int result;
 
-        if ( ForkConfiguration.FORK_NEVER.equals( forkConfiguration.getForkMode() ) )
+        if (  ForkConfiguration.FORK_NEVER.equals( forkConfiguration.getForkMode() ) )
         {
             result = runSuitesInProcess();
         }



Mime
View raw message