You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/12/29 22:31:07 UTC

[GitHub] [maven-invoker] slawekjaranowski commented on a change in pull request #34: [MSHARED-1007] Add MavenHome and MavenExecutable options to InvocationRequest

slawekjaranowski commented on a change in pull request #34:
URL: https://github.com/apache/maven-invoker/pull/34#discussion_r776513396



##########
File path: src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
##########
@@ -599,46 +578,61 @@ protected void setThreads( InvocationRequest request, Commandline cli )
 
     }
 
-    /**
-     * <p>findMavenExecutable.</p>
-     *
-     * @return a {@link java.io.File} object.
-     * @throws org.apache.maven.shared.invoker.CommandLineConfigurationException if any.
-     * @throws java.io.IOException if any.
-     */
-    protected File findMavenExecutable()
-        throws CommandLineConfigurationException, IOException
+    void setupMavenHome( InvocationRequest request )
     {
+        if ( request.getMavenHome() != null )
+        {
+            mavenHome = request.getMavenHome();
+        }
+
         if ( mavenHome == null )
         {
             String mavenHomeProperty = System.getProperty( "maven.home" );
+            if ( mavenHomeProperty == null && getSystemEnvVars().getProperty( "M2_HOME" ) != null )
+            {
+                mavenHomeProperty = getSystemEnvVars().getProperty( "M2_HOME" );
+            }
+
             if ( mavenHomeProperty != null )
             {
                 mavenHome = new File( mavenHomeProperty );
-                if ( !mavenHome.isDirectory() )
-                {
-                    File binDir = mavenHome.getParentFile();
-                    if ( binDir != null && "bin".equals( binDir.getName() ) )
-                    {
-                        // ah, they specified the mvn
-                        // executable instead...
-                        mavenHome = binDir.getParentFile();
-                    }
-                    else
-                    {
-                        throw new IllegalStateException( "${maven.home} is not specified as a directory: '"
-                            + mavenHomeProperty + "'." );
-                    }
-                }
             }
+        }
 
-            if ( ( mavenHome == null ) && ( getSystemEnvVars().getProperty( "M2_HOME" ) != null ) )
+        if ( mavenHome != null && !mavenHome.isDirectory() )

Review comment:
       This code was moved .. someone do it in past
   I didn't want change too much.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org