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 jv...@apache.org on 2006/02/26 21:05:56 UTC

svn commit: r381149 - /maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java

Author: jvanzyl
Date: Sun Feb 26 12:05:54 2006
New Revision: 381149

URL: http://svn.apache.org/viewcvs?rev=381149&view=rev
Log:
[MSUREFIRE-60] workingDirectory in fork mode is not working
submitted by: Dan Tran

Modified:
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java
URL: http://svn.apache.org/viewcvs/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java?rev=381149&r1=381148&r2=381149&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/SurefireBooter.java Sun Feb 26 12:05:54 2006
@@ -376,11 +376,6 @@
 
         }
 
-        if ( workingDirectory != null )
-        {
-            cli.setWorkingDirectory( workingDirectory.getAbsolutePath() );
-        }
-
         cli.createArgument().setValue( "-classpath" );
 
         cli.createArgument().setValue( surefireBooterJar + PS + plexusUtilsJar );
@@ -389,6 +384,13 @@
 
         cli.createArgument().setValue( basedir );
 
+        if ( workingDirectory != null )
+        {
+            //both cli's working directory and  system property "user.dir" must have the same value
+            cli.setWorkingDirectory( workingDirectory.getAbsolutePath() );
+            cli.createArgument().setValue( workingDirectory.getAbsolutePath() );
+        }
+        
         if ( debug )
         {
             System.out.println( Commandline.toString( cli.getCommandline() ) );
@@ -676,6 +678,13 @@
         throws Exception
     {
         String basedir = args[0];
+        
+        String workingDirectory = null;
+        
+        if ( args.length == 2 )
+        {
+            workingDirectory = args[1];
+        }
 
         ClassLoader classLoader = createForkingClassLoader( basedir );
 
@@ -683,6 +692,11 @@
         Thread.currentThread().setContextClassLoader( classLoader );
 
         setSystemProperties( basedir );
+        
+        if ( workingDirectory != null )
+        {
+            System.setProperty( "user.dir", workingDirectory );
+        }
 
         Properties p = getSurefireProperties( basedir );