You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/09/16 16:21:20 UTC

[maven-verifier] branch MSHARED-1137 created (now 3a6f943)

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

sjaranowski pushed a change to branch MSHARED-1137
in repository https://gitbox.apache.org/repos/asf/maven-verifier.git


      at 3a6f943  [MSHARED-1137] get default Maven home only from maven.home system property

This branch includes the following new commits:

     new 3a6f943  [MSHARED-1137] get default Maven home only from maven.home system property

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.



[maven-verifier] 01/01: [MSHARED-1137] get default Maven home only from maven.home system property

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

sjaranowski pushed a commit to branch MSHARED-1137
in repository https://gitbox.apache.org/repos/asf/maven-verifier.git

commit 3a6f943f932b09a1f8b2a34a1f058a7f43758b05
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Fri Sep 16 18:09:05 2022 +0200

    [MSHARED-1137] get default Maven home only from maven.home system property
---
 .../org/apache/maven/shared/verifier/Verifier.java | 35 ++--------------------
 src/site/markdown/getting-started.md               |  2 --
 2 files changed, 2 insertions(+), 35 deletions(-)

diff --git a/src/main/java/org/apache/maven/shared/verifier/Verifier.java b/src/main/java/org/apache/maven/shared/verifier/Verifier.java
index 995e8dd..3581f6a 100644
--- a/src/main/java/org/apache/maven/shared/verifier/Verifier.java
+++ b/src/main/java/org/apache/maven/shared/verifier/Verifier.java
@@ -48,7 +48,6 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
 import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.cli.CommandLineUtils;
 import org.apache.maven.shared.utils.io.FileUtils;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -203,7 +202,7 @@ public class Verifier
         findLocalRepo( settingsFile );
         if ( mavenHome == null )
         {
-            this.mavenHome = getDefaultMavenHome();
+            this.mavenHome = System.getProperty( "maven.home" );
             useWrapper = Files.exists( Paths.get( getBasedir(), "mvnw" ) );
         }
         else
@@ -220,27 +219,6 @@ public class Verifier
         this.defaultCliArguments = defaultCliArguments == null ? new String[0] : defaultCliArguments.clone();
     }
 
-    private static String getDefaultMavenHome()
-    {
-        String defaultMavenHome = System.getProperty( "maven.home" );
-
-        if ( defaultMavenHome == null )
-        {
-            Properties envVars = CommandLineUtils.getSystemEnvVars();
-            defaultMavenHome = envVars.getProperty( "M2_HOME" );
-        }
-
-        if ( defaultMavenHome == null )
-        {
-            File f = new File( System.getProperty( "user.home" ), "m2" );
-            if ( new File( f, "bin/mvn" ).isFile() )
-            {
-                defaultMavenHome = f.getAbsolutePath();
-            }
-        }
-        return defaultMavenHome;
-    }
-
     public void setLocalRepo( String localRepo )
     {
         this.localRepo = localRepo;
@@ -1246,16 +1224,7 @@ public class Verifier
         }
         else
         {
-            File f = new File( System.getProperty( "user.home" ), "m2/bin/mvn" );
-
-            if ( f.exists() )
-            {
-                return f.getAbsolutePath();
-            }
-            else
-            {
-                return "mvn";
-            }
+            return "mvn";
         }
     }
 
diff --git a/src/site/markdown/getting-started.md b/src/site/markdown/getting-started.md
index fc1f620..7e77135 100644
--- a/src/site/markdown/getting-started.md
+++ b/src/site/markdown/getting-started.md
@@ -69,8 +69,6 @@ The following directories are considered as potential Maven home directory (rele
 
 1. Maven Home path given in the constructor
 2. System property `maven.home`
-3. Environment variable `M2_HOME`
-4. System property `user.home` suffixed with `/m2` (only considered if it contains `bin/mvn`)
 
 ### Setting Maven Home for Embedded Launcher