mirror of https://github.com/apache/maven.git
[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.
This commit is contained in:
parent
4337d18af6
commit
065281c43d
|
@ -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
|
||||
|
||||
|
@ -49,7 +42,7 @@ fi
|
|||
# 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;;
|
||||
MINGW*) mingw=true;;
|
||||
|
@ -94,8 +87,7 @@ if [ -z "$JAVA_HOME" ] ; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
## resolve links - $0 may be a link to Maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
|
@ -111,29 +103,27 @@ if [ -z "$M2_HOME" ] ; then
|
|||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
MAVEN_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
MAVEN_HOME=`cd "$MAVEN_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# 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?
|
||||
|
@ -182,13 +172,13 @@ if [ -z "$JAVA_HOME" ] ; then
|
|||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_JAR=`echo "${M2_HOME}"/boot/plexus-classworlds-*.jar`
|
||||
CLASSWORLDS_JAR=`echo "${MAVEN_HOME}"/boot/plexus-classworlds-*.jar`
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$MAVEN_HOME" ] &&
|
||||
MAVEN_HOME=`cygpath --path --windows "$MAVEN_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
|
@ -225,7 +215,7 @@ 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.
|
||||
# executing Maven otherwise this will cause Maven not to consider it.
|
||||
if $cygwin ; then
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
|
@ -242,7 +232,7 @@ 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}" \
|
||||
"-Dlibrary.jansi.path=${MAVEN_HOME}/lib/ext" \
|
||||
${CLASSWORLDS_LAUNCHER} "$@"
|
||||
|
|
|
@ -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
|
||||
|
@ -77,34 +71,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 ====
|
||||
|
||||
|
@ -112,16 +91,16 @@ 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
|
||||
set WDIR=%CD%
|
||||
|
@ -140,7 +119,7 @@ cd "%EXEC_DIR%"
|
|||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
if not exist "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" 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
|
||||
|
@ -148,13 +127,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%" "-Dlibrary.jansi.path=%MAVEN_HOME%\lib\ext" %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%" "-Dlibrary.jansi.path=%MAVEN_HOME%\lib\ext" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
|
|
|
@ -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 "$@"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -346,8 +346,7 @@ public class MavenCli
|
|||
if ( basedirProperty == null )
|
||||
{
|
||||
System.err.format(
|
||||
"-D%s system property is not set." + " Check $M2_HOME environment variable and mvn script match.",
|
||||
MULTIMODULE_PROJECT_DIRECTORY );
|
||||
"-D%s system property is not set.", MULTIMODULE_PROJECT_DIRECTORY );
|
||||
throw new ExitException( 1 );
|
||||
}
|
||||
File basedir = basedirProperty != null ? new File( basedirProperty ) : new File( "" );
|
||||
|
|
Loading…
Reference in New Issue