You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2016/04/14 23:00:36 UTC

maven git commit: [MNG-5607] Don't use M2_HOME in mvn shell/command scripts anymore

Repository: maven
Updated Branches:
  refs/heads/master 59c26ed39 -> fe47a3d79


[MNG-5607] Don't use M2_HOME in mvn shell/command scripts anymore

* Variable has been removed and replaced with an internal one which
  cannot be overriden from outside. From now on, it is an
  implementation detail which it should have been from the beginning.
* Cleaned up license header and style of the variable description
  section graciously borrowed from the Tomcat start scripts.


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/fe47a3d7
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/fe47a3d7
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/fe47a3d7

Branch: refs/heads/master
Commit: fe47a3d79ffbb68a9e64ac5324be7a7544cbed4f
Parents: 59c26ed
Author: Michael Osipov <mi...@apache.org>
Authored: Thu Apr 14 22:41:07 2016 +0200
Committer: Michael Osipov <mi...@apache.org>
Committed: Thu Apr 14 22:41:07 2016 +0200

----------------------------------------------------------------------
 apache-maven/src/bin/mvn          | 94 +++++++++++++++-------------------
 apache-maven/src/bin/mvn.cmd      | 65 ++++++++---------------
 apache-maven/src/bin/mvnDebug     | 25 ++++-----
 apache-maven/src/bin/mvnDebug.cmd | 16 +++---
 apache-maven/src/bin/mvnyjp       | 23 +++------
 5 files changed, 90 insertions(+), 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/fe47a3d7/apache-maven/src/bin/mvn
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn
index c815839..672efbf 100755
--- a/apache-maven/src/bin/mvn
+++ b/apache-maven/src/bin/mvn
@@ -1,5 +1,5 @@
 #!/bin/sh
-# ----------------------------------------------------------------------------
+
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,23 +16,16 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# ----------------------------------------------------------------------------
 
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
+# -----------------------------------------------------------------------------
+# Apache Maven Startup Script
 #
-# Required ENV vars:
-# ------------------
-#   JAVA_HOME - location of a JDK home dir
+# Environment Variable Prerequisites
 #
-# Optional ENV vars
-# -----------------
-#   M2_HOME - location of maven2's installed home dir
-#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
-#     e.g. to debug Maven itself, use
-#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
+#   JAVA_HOME       Must point at your Java Development Kit installation.
+#   MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+#   MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+# -----------------------------------------------------------------------------
 
 if [ -z "$MAVEN_SKIP_RC" ] ; then
 
@@ -46,12 +39,12 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then
 
 fi
 
-# OS specific support.  $var _must_ be set to either true or false.
+# OS specific support. $var _must_ be set to either true or false.
 cygwin=false;
 darwin=false;
-mingw=false
+mingw=false;
 case "`uname`" in
-  CYGWIN*) cygwin=true ;;
+  CYGWIN*) cygwin=true;;
   MINGW*) mingw=true;;
   Darwin*) darwin=true
            #
@@ -94,46 +87,43 @@ if [ -z "$JAVA_HOME" ] ; then
   fi
 fi
 
-if [ -z "$M2_HOME" ] ; then
-  ## resolve links - $0 may be a link to maven's home
-  PRG="$0"
+## resolve links - $0 may be a link to Maven's home
+PRG="$0"
 
-  # need this for relative symlinks
-  while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-      PRG="$link"
-    else
-      PRG="`dirname "$PRG"`/$link"
-    fi
-  done
+# need this for relative symlinks
+while [ -h "$PRG" ] ; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG="`dirname "$PRG"`/$link"
+  fi
+done
 
-  saveddir=`pwd`
+saveddir=`pwd`
 
-  M2_HOME=`dirname "$PRG"`/..
+MAVEN_HOME=`dirname "$PRG"`/..
 
-  # make it fully qualified
-  M2_HOME=`cd "$M2_HOME" && pwd`
+# make it fully qualified
+MAVEN_HOME=`cd "$MAVEN_HOME" && pwd`
 
-  cd "$saveddir"
-  # echo Using m2 at $M2_HOME
-fi
+cd "$saveddir"
 
-# For Cygwin, ensure paths are in UNIX format before anything is touched
+# For Cygwin, ensure paths are in Unix format before anything is touched
 if $cygwin ; then
-  [ -n "$M2_HOME" ] &&
-    M2_HOME=`cygpath --unix "$M2_HOME"`
+  [ -n "$MAVEN_HOME" ] &&
+    MAVEN_HOME=`cygpath --unix "$MAVEN_HOME"`
   [ -n "$JAVA_HOME" ] &&
     JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
   [ -n "$CLASSPATH" ] &&
     CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
 fi
 
-# For Migwn, ensure paths are in UNIX format before anything is touched
+# For MinGW, ensure paths are in Unix format before anything is touched
 if $mingw ; then
-  [ -n "$M2_HOME" ] &&
-    M2_HOME="`(cd "$M2_HOME"; pwd)`"
+  [ -n "$MAVEN_HOME" ] &&
+    MAVEN_HOME="`(cd "$MAVEN_HOME"; pwd)`"
   [ -n "$JAVA_HOME" ] &&
     JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
   # TODO classpath?
@@ -183,12 +173,12 @@ if [ -z "$JAVA_HOME" ] ; then
 fi
 
 CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-CLASSWORLDS_JAR=`echo "${M2_HOME}"/boot/plexus-classworlds-*.jar`
+CLASSWORLDS_JAR=`echo "${MAVEN_HOME}"/boot/plexus-classworlds-*.jar`
 
 # For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
-  [ -n "$M2_HOME" ] &&
-    M2_HOME=`cygpath --path --windows "$M2_HOME"`
+if $cygwin ; then
+  [ -n "$MAVEN_HOME" ] &&
+    MAVEN_HOME=`cygpath --path --windows "$MAVEN_HOME"`
   [ -n "$JAVA_HOME" ] &&
     JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
   [ -n "$CLASSPATH" ] &&
@@ -225,8 +215,8 @@ MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-`find_maven_basedir`}"
 MAVEN_OPTS="`concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"` $MAVEN_OPTS"
 
 # For Cygwin, switch project base directory path to Windows format before
-# executing Maven. Otherwise this will cause Maven not to consider it.
-if $cygwin; then
+# executing Maven otherwise this will cause Maven not to consider it.
+if $cygwin ; then
   [ -n "$MAVEN_PROJECTBASEDIR" ] &&
   MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
 fi
@@ -242,6 +232,6 @@ exec "$JAVACMD" \
   $MAVEN_OPTS \
   $MAVEN_DEBUG_OPTS \
   -classpath "${CLASSWORLDS_JAR}" \
-  "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
-  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  "-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \
+  "-Dmaven.home=${MAVEN_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
   ${CLASSWORLDS_LAUNCHER} "$@"

http://git-wip-us.apache.org/repos/asf/maven/blob/fe47a3d7/apache-maven/src/bin/mvn.cmd
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd
index 12993d9..06a58d1 100644
--- a/apache-maven/src/bin/mvn.cmd
+++ b/apache-maven/src/bin/mvn.cmd
@@ -1,4 +1,3 @@
-@REM ----------------------------------------------------------------------------
 @REM Licensed to the Apache Software Foundation (ASF) under one
 @REM or more contributor license agreements.  See the NOTICE file
 @REM distributed with this work for additional information
@@ -15,23 +14,18 @@
 @REM KIND, either express or implied.  See the License for the
 @REM specific language governing permissions and limitations
 @REM under the License.
-@REM ----------------------------------------------------------------------------
 
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
+@REM -----------------------------------------------------------------------------
+@REM Apache Maven Startup Script
 @REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
+@REM Environment Variable Prerequisites
 @REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM     e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
+@REM   JAVA_HOME          Must point at your Java Development Kit installation.
+@REM   MAVEN_BATCH_ECHO  (Optional) Set to 'on' to enable the echoing of the batch commands.
+@REM   MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending.
+@REM   MAVEN_OPTS        (Optional) Java runtime options used when Maven is executed.
+@REM   MAVEN_SKIP_RC     (Optional) Flag to disable loading of mavenrc files.
+@REM -----------------------------------------------------------------------------
 
 @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
 @echo off
@@ -74,34 +68,19 @@ echo.
 goto error
 
 :chkMHome
-if not "%M2_HOME%"=="" goto valMHome
-
-SET "M2_HOME=%~dp0.."
-if not "%M2_HOME%"=="" goto valMHome
-
-echo.
-echo Error: M2_HOME not found in your environment. >&2
-echo Please set the M2_HOME variable in your environment to match the >&2
-echo location of the Maven installation. >&2
-echo.
+set "MAVEN_HOME=%~dp0.."
+if not "%MAVEN_HOME%"=="" goto valMHome
 goto error
 
 :valMHome
 
 :stripMHome
-if not "_%M2_HOME:~-1%"=="_\" goto checkMCmd
-set "M2_HOME=%M2_HOME:~0,-1%"
+if not "_%MAVEN_HOME:~-1%"=="_\" goto checkMCmd
+set "MAVEN_HOME=%MAVEN_HOME:~0,-1%"
 goto stripMHome
 
 :checkMCmd
-if exist "%M2_HOME%\bin\mvn.cmd" goto init
-
-echo.
-echo Error: M2_HOME is set to an invalid directory. >&2
-echo M2_HOME = "%M2_HOME%" >&2
-echo Please set the M2_HOME variable in your environment to match the >&2
-echo location of the Maven installation >&2
-echo.
+if exist "%MAVEN_HOME%\bin\mvn.cmd" goto init
 goto error
 @REM ==== END VALIDATION ====
 
@@ -109,19 +88,19 @@ goto error
 
 set MAVEN_CMD_LINE_ARGS=%*
 
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Find the project basedir, i.e., the directory that contains the folder ".mvn".
 @REM Fallback to current working directory if not found.
 
 set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+if not "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
 
 set "EXEC_DIR=%CD%"
 set "WDIR=%EXEC_DIR%"
 
 :findBaseDir
-IF EXIST "%WDIR%\.mvn" goto baseDirFound
+if exist "%WDIR%\.mvn" goto baseDirFound
 cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
+if "%WDIR%"=="%CD%" goto baseDirNotFound
 set "WDIR=%CD%"
 goto findBaseDir
 
@@ -138,7 +117,7 @@ cd "%EXEC_DIR%"
 :endDetectBaseDir
 
 set "jvmConfig=\.mvn\jvm.config"
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%%jvmConfig%"  goto endReadAdditionalConfig
+if not exist "%MAVEN_PROJECTBASEDIR%%jvmConfig%"  goto endReadAdditionalConfig
 
 @setlocal EnableExtensions EnableDelayedExpansion
 for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@@ -146,13 +125,13 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s
 
 :endReadAdditionalConfig
 
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
 
-for %%i in ("%M2_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
+for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
 
 set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
 
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" "-Dmaven.home=%MAVEN_HOME%" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
 if ERRORLEVEL 1 goto error
 goto end
 

http://git-wip-us.apache.org/repos/asf/maven/blob/fe47a3d7/apache-maven/src/bin/mvnDebug
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/mvnDebug b/apache-maven/src/bin/mvnDebug
index caf0b45..be495ff 100755
--- a/apache-maven/src/bin/mvnDebug
+++ b/apache-maven/src/bin/mvnDebug
@@ -1,5 +1,5 @@
 #!/bin/sh
-# ----------------------------------------------------------------------------
+
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,26 +16,19 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# ----------------------------------------------------------------------------
 
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
+# -----------------------------------------------------------------------------
+# Apache Maven Debug Script
 #
-# Required ENV vars:
-# ------------------
-#   JAVA_HOME - location of a JDK home dir
+# Environment Variable Prerequisites
 #
-# Optional ENV vars
-# -----------------
-#   M2_HOME - location of maven2's installed home dir
-#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
-#     e.g. to debug Maven itself, use
-#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
+#   JAVA_HOME       Must point at your Java Development Kit installation.
+#   MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+#   MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+# -----------------------------------------------------------------------------
 
 MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
 
-echo Preparing to Execute Maven in Debug Mode
+echo Preparing to execute Maven in debug mode
 
 env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvn" "$@"

http://git-wip-us.apache.org/repos/asf/maven/blob/fe47a3d7/apache-maven/src/bin/mvnDebug.cmd
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/mvnDebug.cmd b/apache-maven/src/bin/mvnDebug.cmd
index 1f0d3bf..5f9a20a 100644
--- a/apache-maven/src/bin/mvnDebug.cmd
+++ b/apache-maven/src/bin/mvnDebug.cmd
@@ -1,4 +1,3 @@
-@REM ----------------------------------------------------------------------------
 @REM Licensed to the Apache Software Foundation (ASF) under one
 @REM or more contributor license agreements.  See the NOTICE file
 @REM distributed with this work for additional information
@@ -15,15 +14,18 @@
 @REM KIND, either express or implied.  See the License for the
 @REM specific language governing permissions and limitations
 @REM under the License.
-@REM ----------------------------------------------------------------------------
 
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script to run mvn.cmd with the following additional
-@REM Java VM settings:
+@REM -----------------------------------------------------------------------------
+@REM Apache Maven Debug Script
 @REM
-@REM     -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM Environment Variable Prerequisites
 @REM
-@REM ----------------------------------------------------------------------------
+@REM   JAVA_HOME          Must point at your Java Development Kit installation.
+@REM   MAVEN_BATCH_ECHO  (Optional) Set to 'on' to enable the echoing of the batch commands.
+@REM   MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending.
+@REM   MAVEN_OPTS        (Optional) Java runtime options used when Maven is executed.
+@REM   MAVEN_SKIP_RC     (Optional) Flag to disable loading of mavenrc files.
+@REM -----------------------------------------------------------------------------
 
 @setlocal
 @set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

http://git-wip-us.apache.org/repos/asf/maven/blob/fe47a3d7/apache-maven/src/bin/mvnyjp
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/mvnyjp b/apache-maven/src/bin/mvnyjp
index 3ddec42..a35eabf 100755
--- a/apache-maven/src/bin/mvnyjp
+++ b/apache-maven/src/bin/mvnyjp
@@ -1,5 +1,5 @@
 #!/bin/sh
-# ----------------------------------------------------------------------------
+
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,23 +16,16 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# ----------------------------------------------------------------------------
 
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
+# -----------------------------------------------------------------------------
+# Apache Maven YourKit Profiler Startup Script
 #
-# Required ENV vars:
-# ------------------
-#   JAVA_HOME - location of a JDK home dir
+# Environment Variable Prerequisites
 #
-# Optional ENV vars
-# -----------------
-#   M2_HOME - location of maven2's installed home dir
-#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
-#     e.g. to debug Maven itself, use
-#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
+#   JAVA_HOME       Must point at your Java Development Kit installation.
+#   MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+#   MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+# -----------------------------------------------------------------------------
 
 if [ ! -f "$YJPLIB" ]; then
   echo "Error: Unable to autodetect the YJP library location. Please set YJPLIB variable" >&2