This is an automated email from the ASF dual-hosted git repository.

mthmulders pushed a commit to branch mng-6118-submodule-invocation
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git

commit 36b72690a315fd23c82b9eef3666e90e7a11dce4
Author: Maarten Mulders <mthmuld...@apache.org>
AuthorDate: Wed Sep 9 13:54:57 2020 +0200

    [MNG-6118] Override MAVEN_BASEDIR environment variable
---
 .../it/MavenITmng6118SubmoduleInvocation.java      | 28 +++++++++++-----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git 
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6118SubmoduleInvocation.java
 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6118SubmoduleInvocation.java
index cbc8dd0..6726056 100644
--- 
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6118SubmoduleInvocation.java
+++ 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6118SubmoduleInvocation.java
@@ -23,6 +23,8 @@ import org.apache.maven.it.util.ResourceExtractor;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This is a collection of test cases for <a 
href="https://issues.apache.org/jira/browse/MNG-6118";>MNG-6118</a>,
@@ -40,10 +42,16 @@ import java.io.IOException;
 public class MavenITmng6118SubmoduleInvocation extends 
AbstractMavenIntegrationTestCase
 {
     private static final String RESOURCE_PATH = 
"/mng-6118-submodule-invocation-full-reactor";
+    private final File testDir;
+    private final Map<String, String> envVars = new HashMap<>();
 
-    public MavenITmng6118SubmoduleInvocation()
+    public MavenITmng6118SubmoduleInvocation() throws IOException
     {
         super( "[3.7.0,)" );
+        testDir = ResourceExtractor.simpleExtractResources( getClass(), 
RESOURCE_PATH );
+        // It seems MAVEN_BASEDIR isn't always properly set, so make sure to 
have the right value here
+        // as it is determined by the mvn script.
+        envVars.put( "MAVEN_BASEDIR", testDir.getAbsolutePath() );
     }
 
     /**
@@ -51,17 +59,15 @@ public class MavenITmng6118SubmoduleInvocation extends 
AbstractMavenIntegrationT
      */
     public void testInSubModule() throws IOException, VerificationException
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
RESOURCE_PATH );
-
         // Compile the whole project first.
         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
-        verifier.executeGoal( "compile" );
+        verifier.executeGoal( "compile", envVars );
 
         final File submoduleDirectory = new File( testDir, "app" );
         verifier = newVerifier( submoduleDirectory.getAbsolutePath() );
         verifier.setAutoclean( false );
         verifier.setLogFileName( "log-insubmodule.txt" );
-        verifier.executeGoal( "compile" );
+        verifier.executeGoal( "compile", envVars );
     }
 
     /**
@@ -69,8 +75,6 @@ public class MavenITmng6118SubmoduleInvocation extends 
AbstractMavenIntegrationT
      */
     public void testWithFile() throws IOException, VerificationException
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
RESOURCE_PATH );
-
         // Compile the whole project first.
         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
         verifier.executeGoal( "compile" );
@@ -79,7 +83,7 @@ public class MavenITmng6118SubmoduleInvocation extends 
AbstractMavenIntegrationT
         verifier.setAutoclean( false );
         verifier.setLogFileName( "log-withfile.txt" );
         verifier.addCliOption( "-f app/pom.xml" );
-        verifier.executeGoal( "compile" );
+        verifier.executeGoal( "compile", envVars );
     }
 
     /**
@@ -87,13 +91,11 @@ public class MavenITmng6118SubmoduleInvocation extends 
AbstractMavenIntegrationT
      */
     public void testWithFileAndAlsoMake() throws IOException, 
VerificationException
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
RESOURCE_PATH );
-
         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
         verifier.addCliOption( "-am" );
         verifier.addCliOption( "-f app/pom.xml" );
         verifier.setLogFileName( "log-withfilealsomake.txt" );
-        verifier.executeGoal( "compile" );
+        verifier.executeGoal( "compile", envVars );
         verifier.verifyTextInLog( "Building Maven Integration Test :: MNG-6118 
:: Library 1.0" );
     }
 
@@ -102,13 +104,11 @@ public class MavenITmng6118SubmoduleInvocation extends 
AbstractMavenIntegrationT
      */
     public void testInSubModuleWithAlsoMake() throws IOException, 
VerificationException
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
RESOURCE_PATH );
-
         File submoduleDirectory = new File( testDir, "app" );
         Verifier verifier = newVerifier( submoduleDirectory.getAbsolutePath() 
);
         verifier.addCliOption( "-am" );
         verifier.setLogFileName( "log-insubmodulealsomake.txt" );
-        verifier.executeGoal( "compile" );
+        verifier.executeGoal( "compile", envVars );
         verifier.verifyTextInLog( "Building Maven Integration Test :: MNG-6118 
:: Library 1.0" );
     }
 }

Reply via email to