You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/02/03 00:11:35 UTC

[maven-invoker] branch MSHARED-577 updated (a270e55 -> ff0176e)

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

slachiewicz pushed a change to branch MSHARED-577
in repository https://gitbox.apache.org/repos/asf/maven-invoker.git.


 discard a270e55  [MSHARED-577] Remove M2_HOME
 discard 39dad0a  [MINVOKER-269] add 'quiet' flag
     add 3f8441f  [MSHARED-978] add 'quiet' flag
     add bd25b52  (doc) misc test updates
     add 1fbcab6  Switch to 3.1.0-SNAPSHOT
     new ff0176e  [MSHARED-577] Remove M2_HOME

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a270e55)
            \
             N -- N -- N   refs/heads/MSHARED-577 (ff0176e)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                                        |  3 +--
 .../org/apache/maven/shared/invoker/DefaultInvokerTest.java    |  2 +-
 .../maven/shared/invoker/MavenCommandLineBuilderTest.java      | 10 ++++++----
 src/test/resources/test-build-should-succeed/pom.xml           |  2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)


[maven-invoker] 01/01: [MSHARED-577] Remove M2_HOME

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MSHARED-577
in repository https://gitbox.apache.org/repos/asf/maven-invoker.git

commit ff0176e22a44091b494f095f09f1faeeea012696
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Wed Feb 3 01:11:18 2021 +0100

    [MSHARED-577] Remove M2_HOME
---
 .../java/org/apache/maven/shared/invoker/Invoker.java |  2 +-
 .../maven/shared/invoker/MavenCommandLineBuilder.java | 19 +++----------------
 src/site/apt/usage.apt                                |  2 +-
 .../maven/shared/invoker/DefaultInvokerTest.java      |  8 +-------
 .../shared/invoker/MavenCommandLineBuilderTest.java   |  7 +++----
 5 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/invoker/Invoker.java b/src/main/java/org/apache/maven/shared/invoker/Invoker.java
index 369be70..63f2fdd 100644
--- a/src/main/java/org/apache/maven/shared/invoker/Invoker.java
+++ b/src/main/java/org/apache/maven/shared/invoker/Invoker.java
@@ -80,7 +80,7 @@ public interface Invoker
     /**
      * Sets the path to the base directory of the Maven installation used to invoke Maven. This parameter may be left
      * unspecified to use the default Maven installation which will be discovered by evaluating the system property
-     * <code>maven.home</code> and the environment variable <code>M2_HOME</code>.
+     * <code>maven.home</code>.
      * 
      * @param mavenHome The path to the base directory of the Maven installation, may be <code>null</code> to use the
      *            default Maven installation.
diff --git a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
index 1b89595..bf53481 100644
--- a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
+++ b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
@@ -119,15 +119,10 @@ public class MavenCommandLineBuilder
         }
 
         if ( ( mavenHome == null ) && ( System.getProperty( "maven.home" ) == null ) )
-        // can be restored with 1.5
-        // && ( System.getenv( "M2_HOME" ) != null ) )
         {
-            if ( !getSystemEnvVars().containsKey( "M2_HOME" ) )
-            {
-                throw new IllegalStateException( "Maven application directory was not "
-                    + "specified, and ${maven.home} is not provided in the system "
-                    + "properties. Specify at least one of these." );
-            }
+            throw new IllegalStateException( "Maven application directory was not "
+                + "specified, and ${maven.home} is not provided in the system "
+                + "properties. Specify at least one of these." );
         }
     }
 
@@ -201,9 +196,6 @@ public class MavenCommandLineBuilder
             {
                 cli.addSystemEnvironment();
                 cli.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );
-                // MSHARED-261: Ensure M2_HOME is not inherited, but gets a
-                // proper value
-                cli.addEnvironment( "M2_HOME", getMavenHome().getAbsolutePath() );
             }
             catch ( RuntimeException e )
             {
@@ -544,11 +536,6 @@ public class MavenCommandLineBuilder
                     }
                 }
             }
-
-            if ( ( mavenHome == null ) && ( getSystemEnvVars().getProperty( "M2_HOME" ) != null ) )
-            {
-                mavenHome = new File( getSystemEnvVars().getProperty( "M2_HOME" ) );
-            }
         }
 
         logger.debug( "Using ${maven.home} of: '" + mavenHome + "'." );
diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt
index c870567..f23832f 100644
--- a/src/site/apt/usage.apt
+++ b/src/site/apt/usage.apt
@@ -127,7 +127,7 @@ public void publishSite( File siteDirectory ) throws PublishException
 
   You can use the method <<<Invoker.setMavenHome()>>> to specify which Maven executable it should use.
   If you don't provide an explicit value for this setting, the <<<Invoker>>> will automatically try to detect
-  a Maven installation by evaluating the system property <<<maven.home>>> and the environment variable <<<M2_HOME>>>.
+  a Maven installation by evaluating the system property <<<maven.home>>>.
 
   <<Note:>> If you use the invocation API in tests run by the {{{../../plugins/maven-surefire-plugin}Maven Surefire Plugin}},
   you need to tell Surefire to pass the system property <<<maven.home>>> to the tests in order for the automatic Maven
diff --git a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
index 6fe7c93..09a6328 100644
--- a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
@@ -231,16 +231,10 @@ public class DefaultInvokerTest
     private File findMavenHome()
     {
         String mavenHome = System.getProperty( "maven.home" );
-
-        if ( mavenHome == null )
-        {
-            mavenHome = CommandLineUtils.getSystemEnvVars().getProperty( "M2_HOME" );
-        }
-
         if ( mavenHome == null )
         {
             throw new IllegalStateException( "Cannot find Maven application "
-                + "directory. Either specify 'maven.home' system property, or M2_HOME environment variable." );
+                + "directory. Please specify 'maven.home' system property" );
         }
 
         return new File( mavenHome );
diff --git a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
index 56129bd..2a73bf2 100644
--- a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
@@ -43,6 +43,7 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeThat;
@@ -815,11 +816,9 @@ public class MavenCommandLineBuilderTest
     }
 
     @Test
-    public void testShouldSetEnvVar_M2_HOME()
+    public void testShouldNotSetEnvVar_M2_HOME()
         throws Exception
     {
-        Assume.assumeNotNull( System.getenv( "M2_HOME" ) );
-
         setupTempMavenHomeIfMissing( true );
 
         InvocationRequest request = newRequest();
@@ -850,7 +849,7 @@ public class MavenCommandLineBuilderTest
                 m2Home = envVar;
             }
         }
-        assertEquals( "M2_HOME=" + mavenHome2.getAbsolutePath(), m2Home );
+        assertNull( "M2_HOME=" + mavenHome2.getAbsolutePath(), m2Home );
     }
 
     @Test