maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1666746 - in /maven/shared/trunk/maven-invoker: pom.xml src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
Date Sat, 14 Mar 2015 21:06:59 GMT
Author: rfscholte
Date: Sat Mar 14 21:06:58 2015
New Revision: 1666746

URL: http://svn.apache.org/r1666746
Log:
[MSHARED-411] maven-invoker - addShellEnvironment forgets variable settings on successive
calls

Modified:
    maven/shared/trunk/maven-invoker/pom.xml
    maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
    maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java

Modified: maven/shared/trunk/maven-invoker/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-invoker/pom.xml?rev=1666746&r1=1666745&r2=1666746&view=diff
==============================================================================
--- maven/shared/trunk/maven-invoker/pom.xml (original)
+++ maven/shared/trunk/maven-invoker/pom.xml Sat Mar 14 21:06:58 2015
@@ -53,6 +53,9 @@ under the License.
 
   <contributors>
     <contributor>
+      <name>Holger Mense</name>
+    </contributor>
+    <contributor>
       <name>Lucien Weller</name>
     </contributor>
   </contributors>

Modified: maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java?rev=1666746&r1=1666745&r2=1666746&view=diff
==============================================================================
--- maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
(original)
+++ maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
Sat Mar 14 21:06:58 2015
@@ -282,6 +282,9 @@ public class DefaultInvocationRequest
         return this;
     }
 
+    /**
+     * @see MavenCommandLineBuilder#setShellEnvironment(InvocationRequest, org.codehaus.plexus.util.cli.Commandline)
+     */
     public boolean isShellEnvironmentInherited()
     {
         return shellEnvironmentInherited;
@@ -383,7 +386,7 @@ public class DefaultInvocationRequest
 
     public InvocationRequest addShellEnvironment( String name, String value )
     {
-        if ( this.shellEnvironmentInherited )
+        if ( this.shellEnvironments == null )
         {
             this.shellEnvironments = new HashMap<String, String>();
         }

Modified: maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java?rev=1666746&r1=1666745&r2=1666746&view=diff
==============================================================================
--- maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
(original)
+++ maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
Sat Mar 14 21:06:58 2015
@@ -33,6 +33,7 @@ import java.util.Set;
 import junit.framework.TestCase;
 
 import org.codehaus.plexus.util.Os;
+import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.Commandline;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
@@ -1105,6 +1106,30 @@ public class MavenCommandLineBuilderTest
         assertTrue( "Expected executable to be absolute", executable.isAbsolute() );
     }
     
+    public void testAddShellEnvironment()
+        throws Exception
+    {
+        setupTempMavenHomeIfMissing();
+
+        InvocationRequest request = newRequest();
+
+        String envVar1Name = "VAR-1";
+        String envVar1Value = "VAR-1-VALUE";
+
+        String envVar2Name = "VAR-2";
+        String envVar2Value = "VAR-2-VALUE";
+
+        request.addShellEnvironment( envVar1Name, envVar1Value );
+        request.addShellEnvironment( envVar2Name, envVar2Value );
+
+        MavenCommandLineBuilder commandLineBuilder = new MavenCommandLineBuilder();
+
+        Commandline commandline = commandLineBuilder.build( request );
+
+        assertEnvironmentVariablePresent( commandline, envVar1Name, envVar1Value );
+        assertEnvironmentVariablePresent( commandline, envVar2Name, envVar2Value );
+    }
+    
     public void setUp()
     {
         sysProps = System.getProperties();
@@ -1144,6 +1169,17 @@ public class MavenCommandLineBuilderTest
         System.out.println( "Starting: " + element.getMethodName() );
     }
 
+    private void assertEnvironmentVariablePresent( Commandline cli, String varName, String
varValue )
+        throws CommandLineException
+    {
+        List<String> environmentVariables = Arrays.asList( cli.getEnvironmentVariables()
);
+
+        String expectedDeclaration = varName + "=" + varValue;
+
+        assertTrue( "Environment variable setting: \'" + expectedDeclaration + "\' is mssing
in "
+            + environmentVariables, environmentVariables.contains( expectedDeclaration )
);
+    }
+    
     private void assertArgumentsPresentInOrder( Commandline cli, String... expected )
     {
         assertArgumentsPresentInOrder( cli, Arrays.asList( expected ) );



Mime
View raw message