You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by mk...@apache.org on 2008/01/20 12:52:22 UTC

svn commit: r613539 - in /maven/surefire/trunk: maven-surefire-plugin/pom.xml maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java

Author: mkleint
Date: Sun Jan 20 03:52:21 2008
New Revision: 613539

URL: http://svn.apache.org/viewvc?rev=613539&view=rev
Log:
SUREFIRE-121 copy System properties from MavenSession.getExecutionProperties() mand not from System.getProperties(). fixes forked execution in embedded environment. Also call System.setProperties() only when execution was not forked.

Modified:
    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/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java

Modified: maven/surefire/trunk/maven-surefire-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/pom.xml?rev=613539&r1=613538&r2=613539&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/pom.xml (original)
+++ maven/surefire/trunk/maven-surefire-plugin/pom.xml Sun Jan 20 03:52:21 2008
@@ -109,6 +109,11 @@
       <artifactId>maven-project</artifactId>
       <version>2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+      <version>2.0</version>
+    </dependency>
   </dependencies>
 
   <profiles>

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=613539&r1=613538&r2=613539&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 Sun Jan 20 03:52:21 2008
@@ -58,6 +58,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import org.apache.maven.execution.MavenSession;
 
 /**
  * Run tests using Surefire.
@@ -465,6 +466,16 @@
      * @parameter expression="${enableAssertions}" default-value="true"
      */
     private boolean enableAssertions;
+    
+    /**
+     * The current build session instance. 
+     *
+     * @parameter expression="${session}"
+     * @required
+     * @readonly
+     */
+    private MavenSession session;
+    
 
     public void execute()
         throws MojoExecutionException, MojoFailureException
@@ -489,9 +500,9 @@
                 throw new MojoExecutionException( e.getMessage(), e );
             }
 
-            if ( originalSystemProperties != null )
+            if ( originalSystemProperties != null  && !surefireBooter.isForking() )
             {
-                // restore system properties
+                // restore system properties, only makes sense when not forking..
                 System.setProperties( originalSystemProperties );
             }
 
@@ -947,8 +958,9 @@
         originalSystemProperties = (Properties) System.getProperties().clone();
         
         // SUREFIRE-121 overlay our system properties with user specified properties
-        // Is this wise?
-        Properties userSpecifiedProperties = (Properties) System.getProperties().clone();
+        // Is this wise? 
+        // Get the properties from the MavenSession instance to make embedded use work correctly
+        Properties userSpecifiedProperties = (Properties) session.getExecutionProperties().clone();
         userSpecifiedProperties.putAll( systemProperties );
         systemProperties = userSpecifiedProperties;
 

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=613539&r1=613538&r2=613539&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 Sun Jan 20 03:52:21 2008
@@ -226,6 +226,10 @@
     {
         this.forkConfiguration = forkConfiguration;
     }
+    
+    public boolean isForking() {
+        return forkConfiguration.isForking();
+    }
 
     public int run()
         throws SurefireBooterForkException, SurefireExecutionException