michael-o commented on a change in pull request #34:
URL: https://github.com/apache/maven-invoker/pull/34#discussion_r776512080
##########
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 confuses me. Do you assume that someone will pass the executable to
`mavenHome`?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]