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

[maven-wrapper-plugin] branch MWRAPPER-16 updated (58048e2 -> cb41b03)

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

hboutemy pushed a change to branch MWRAPPER-16
in repository https://gitbox.apache.org/repos/asf/maven-wrapper-plugin.git.


 discard 58048e2  [MWRAPPER-16] PoC call mvn(.cmd) script from mvnw(.cmd)
     add 53b6c58  [MWRAPPER-14] require maven-assembly-plugin 3.3.0 (3.2.0 inherited)
     new cb41b03  [MWRAPPER-16] PoC call mvn(.cmd) script from mvnw(.cmd)

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   (58048e2)
            \
             N -- N -- N   refs/heads/MWRAPPER-16 (cb41b03)

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:
 maven-wrapper-distribution/pom.xml | 1 +
 1 file changed, 1 insertion(+)

[maven-wrapper-plugin] 01/01: [MWRAPPER-16] PoC call mvn(.cmd) script from mvnw(.cmd)

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

hboutemy pushed a commit to branch MWRAPPER-16
in repository https://gitbox.apache.org/repos/asf/maven-wrapper-plugin.git

commit cb41b0340cd2b90025d01468349cefc4a44781fe
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Nov 20 17:35:08 2021 +0100

    [MWRAPPER-16] PoC call mvn(.cmd) script from mvnw(.cmd)
---
 maven-wrapper-distribution/src/assembly/maven/run        | 16 +++++++++++++++-
 maven-wrapper-distribution/src/assembly/maven/run.cmd    | 12 ++++++++++++
 .../org/apache/maven/plugins/wrapper/WrapperMojo.java    |  2 +-
 .../org/apache/maven/wrapper/BootstrapMainStarter.java   |  4 +++-
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/maven-wrapper-distribution/src/assembly/maven/run b/maven-wrapper-distribution/src/assembly/maven/run
index 69535d6..95897e9 100755
--- a/maven-wrapper-distribution/src/assembly/maven/run
+++ b/maven-wrapper-distribution/src/assembly/maven/run
@@ -8,7 +8,7 @@ if $cygwin || $mingw ; then
   MAVEN_PROJECTBASEDIR=`cygpath --windows "$MAVEN_PROJECTBASEDIR"`
 fi
 
-exec "$JAVACMD" \
+"$JAVACMD" \
   $MAVEN_OPTS \
   $MAVEN_DEBUG_OPTS \
   -classpath "$LAUNCHER_JAR" \
@@ -17,3 +17,17 @@ exec "$JAVACMD" \
   "-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \
   "-Dmaven.multiModuleProjectDirectory=$MAVEN_PROJECTBASEDIR" \
   $LAUNCHER_CLASS "$@"
+
+# read distributionUrl from $MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties
+while IFS="=" read key value; do
+  case "$key" in (distributionUrl) distributionUrl="$value"; break ;;
+  esac
+done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+
+# local distribution dir is distributionUrl basename without extension
+distribution=`basename $distributionUrl .zip`
+
+mvn=~/.m2/wrapper/dists/$distribution/*/bin/mvn
+echo "mvnw will call $mvn"
+
+exec $mvn "$@"
diff --git a/maven-wrapper-distribution/src/assembly/maven/run.cmd b/maven-wrapper-distribution/src/assembly/maven/run.cmd
index ac526f8..690f3fa 100755
--- a/maven-wrapper-distribution/src/assembly/maven/run.cmd
+++ b/maven-wrapper-distribution/src/assembly/maven/run.cmd
@@ -9,6 +9,18 @@
   "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
   %LAUNCHER_CLASS% %*
 if ERRORLEVEL 1 goto error
+
+@REM read distributionUrl from $MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties
+FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+    IF "%%A"=="distributionUrl" SET DISTRIBUTION_URL=%%B
+)
+
+for /F %i in (%DISTRIBUTION_URL%) do SET DISTRIBUTION=%~ni
+
+SET MVN=%USERPROFILE%\.m2\wrapper\dists\%DISTRIBUTION%/*/bin/mvn.cmd
+
+%MVN% %*
+
 goto end
 
 :error
diff --git a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
index b8f5295..f745b8d 100644
--- a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
+++ b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
@@ -218,7 +218,7 @@ public class WrapperMojo extends AbstractMojo
         try ( BufferedWriter out = Files.newBufferedWriter( wrapperPropertiesFile ) )
         {
             out.append( license );
-            out.append( "distributionUrl=" + distributionUrl );
+            out.append( "distributionUrl=" + distributionUrl + "\n" );
         }
     }
     
diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java
index 720b450..b29e2ab 100644
--- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java
+++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java
@@ -31,6 +31,7 @@ import java.util.stream.Stream;
  * Maven starter, from a provided Maven home directory.
  *
  * @author Hans Dockter
+ * @deprecated will be removed once launching Maven is not done here but in mvnw script by calling mvn
  */
 public class BootstrapMainStarter
 {
@@ -47,7 +48,8 @@ public class BootstrapMainStarter
         System.setProperty( "classworlds.conf", mavenHome.resolve( "bin/m2.conf" ).toAbsolutePath().toString() );
 
         Method mainMethod = mainClass.getMethod( "main", String[].class );
-        mainMethod.invoke( null, new Object[] { args } );
+        //mainMethod.invoke( null, new Object[] { args } );
+        System.out.println( "Now, mvnw script should call " + mavenHome.toAbsolutePath().toString() + "/bin/mvn" );
     }
 
     private Path findLauncherJar( Path mavenHome ) throws RuntimeException, IOException