From b0e468190e67906c7e1aae54ca440c1d4e7dc626 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 16 Dec 2010 20:03:37 +0000 Subject: [PATCH] [MNG-4937] Allow the platform scripts to avoid loading mavenrc content Submitted by: Jason Dillon git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1050135 13f79535-47bb-0310-9956-ffa450edef68 --- apache-maven/src/bin/mvn | 15 ++++++++++----- apache-maven/src/bin/mvn.bat | 7 +++++++ apache-maven/src/bin/mvnDebug | 15 ++++++++++----- apache-maven/src/bin/mvnDebug.bat | 7 +++++++ apache-maven/src/bin/mvnyjp | 15 ++++++++++----- 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index 7e6394b842..9131f027f4 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -31,14 +31,19 @@ # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files # ---------------------------------------------------------------------------- -if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc -fi +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi -if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" fi # OS specific support. $var _must_ be set to either true or false. diff --git a/apache-maven/src/bin/mvn.bat b/apache-maven/src/bin/mvn.bat index 7702c064a4..b4609be683 100644 --- a/apache-maven/src/bin/mvn.bat +++ b/apache-maven/src/bin/mvn.bat @@ -30,6 +30,7 @@ @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 -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files @REM ---------------------------------------------------------------------------- @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @@ -41,7 +42,9 @@ if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") @REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +:skipRcPre set ERROR_CODE=0 @@ -179,7 +182,11 @@ goto postExec @endlocal & set ERROR_CODE=%ERROR_CODE% :postExec + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +:skipRcPost + @REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on' if "%MAVEN_BATCH_PAUSE%" == "on" pause diff --git a/apache-maven/src/bin/mvnDebug b/apache-maven/src/bin/mvnDebug index da8441c6e2..0e3d13e667 100755 --- a/apache-maven/src/bin/mvnDebug +++ b/apache-maven/src/bin/mvnDebug @@ -31,18 +31,23 @@ # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files # ---------------------------------------------------------------------------- MAVEN_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" echo Preparing to Execute Maven in Debug Mode -if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc -fi +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi -if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" fi # OS specific support. $var _must_ be set to either true or false. diff --git a/apache-maven/src/bin/mvnDebug.bat b/apache-maven/src/bin/mvnDebug.bat index 28d7144be2..d50f53581b 100644 --- a/apache-maven/src/bin/mvnDebug.bat +++ b/apache-maven/src/bin/mvnDebug.bat @@ -30,6 +30,7 @@ @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 -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files @REM ---------------------------------------------------------------------------- @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @@ -43,7 +44,9 @@ if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") @REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +:skipRcPre set ERROR_CODE=0 @@ -183,7 +186,11 @@ goto postExec @endlocal & set ERROR_CODE=%ERROR_CODE% :postExec + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +:skipRcPost + @REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on' if "%MAVEN_BATCH_PAUSE%" == "on" pause diff --git a/apache-maven/src/bin/mvnyjp b/apache-maven/src/bin/mvnyjp index bf5ed537f6..dde92a5162 100755 --- a/apache-maven/src/bin/mvnyjp +++ b/apache-maven/src/bin/mvnyjp @@ -31,6 +31,7 @@ # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files # ---------------------------------------------------------------------------- QUOTED_ARGS="" @@ -41,12 +42,16 @@ while [ "$1" != "" ] ; do done -if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc -fi +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi -if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" fi # OS specific support. $var _must_ be set to either true or false.