Repository: maven-scm Updated Branches: refs/heads/master 3254f99e2 -> 0be4b4259
SCM-836: Corrected mavenHome parameter handling Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/0be4b425 Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/0be4b425 Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/0be4b425 Branch: refs/heads/master Commit: 0be4b4259af486bf8cbf218a30be3af2c12e910f Parents: 3254f99 Author: dantran <dant...@apache.org> Authored: Wed Aug 24 01:59:31 2016 -0700 Committer: dantran <dan.t...@apache.org> Committed: Wed Aug 24 01:59:31 2016 -0700 ---------------------------------------------------------------------- .../apache/maven/scm/plugin/BootstrapMojo.java | 37 +++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-scm/blob/0be4b425/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java ---------------------------------------------------------------------- diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java index 28949b6..4f5a4d6 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java @@ -1,5 +1,7 @@ package org.apache.maven.scm.plugin; +import java.io.File; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -24,6 +26,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.scm.ScmResult; import org.apache.maven.scm.command.checkout.CheckOutScmResult; +import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; @@ -31,8 +34,6 @@ import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.DefaultConsumer; import org.codehaus.plexus.util.cli.StreamConsumer; -import java.io.File; - /** * Pull the project source from the configured scm and execute the configured goals. * @@ -62,14 +63,14 @@ public class BootstrapMojo * The project directory is the same as the checkout directory in most cases, * but for some SCMs, it is a subdirectory of the checkout directory. */ - @Parameter( property = "goalsDirectory", defaultValue = "" ) + @Parameter( property = "goalsDirectory" ) private String goalsDirectory; - + /** - * The path where you maven is installed + * The path where your maven is installed */ - @Parameter( property = "mavenHome", defaultValue = "" ) - private String mavenHome; + @Parameter( property = "mavenHome", defaultValue="${maven.home}") + private File mavenHome; /** {@inheritDoc} */ public void execute() @@ -79,11 +80,11 @@ public class BootstrapMojo if ( this.getCheckoutResult() != null ) { - + ScmResult checkoutResult = this.getCheckoutResult(); - + //At the time of useExport feature is requested only SVN and and CVS have export command implemented - // we will deal with this as more user using this feature specially clearcase where we need to + // we will deal with this as more user using this feature specially clearcase where we need to // add relativePathProjectDirectory support to ExportScmResult String relativePathProjectDirectory = ""; if ( checkoutResult instanceof CheckOutScmResult ) @@ -114,13 +115,23 @@ public class BootstrapMojo } cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" ); - if ( "".equals( this.mavenHome ) ) + if ( this.mavenHome == null ) { - cl.setExecutable( "mvn" ); + cl.setExecutable( "mvn" );//none windows only } else { - cl.setExecutable( this.mavenHome.concat( "/bin/mvn" ) ); + String mvnPath = this.mavenHome.getAbsolutePath() + "/bin/mvn"; + if ( Os.isFamily( "windows" ) ) + { + String winMvnPath = mvnPath + ".cmd"; + if ( !new File( winMvnPath ).exists() ) + { + winMvnPath = mvnPath + ".bat"; + } + mvnPath = winMvnPath; + } + cl.setExecutable( mvnPath ); } cl.setWorkingDirectory( determineWorkingDirectoryPath( this.getCheckoutDirectory(), //