From 5acdfb665035c5e57c50a9f8198dee53da674df6 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 2 Aug 2021 19:46:38 +0200 Subject: [PATCH] [MNG-7205] Simplify/unify Cygwin/MingGW handling in startup scripts This closes #520 --- apache-maven/src/assembly/shared/init | 28 +++----------------- apache-maven/src/assembly/shared/mvnlauncher | 2 +- apache-maven/src/assembly/shared/run | 20 +++++++------- apache-maven/src/assembly/shared/validate | 1 - 4 files changed, 13 insertions(+), 38 deletions(-) diff --git a/apache-maven/src/assembly/shared/init b/apache-maven/src/assembly/shared/init index d1c79b2a33..fe8780b4b2 100755 --- a/apache-maven/src/assembly/shared/init +++ b/apache-maven/src/assembly/shared/init @@ -1,21 +1,9 @@ -CLASSWORLDS_CONF="${MAVEN_HOME}/bin/m2.conf" +CLASSWORLDS_CONF="$MAVEN_HOME/bin/m2.conf" -# For Cygwin, ensure paths are in Unix format before anything is touched -if $cygwin ; then - [ -n "$MAVEN_HOME" ] && - MAVEN_HOME=`cygpath --unix "$MAVEN_HOME"` +# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched +if $cygwin || $mingw ; then [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in Unix format before anything is touched -if $mingw ; then - [ -n "$MAVEN_HOME" ] && - MAVEN_HOME=`(cd "$MAVEN_HOME"; pwd)` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`(cd "$JAVA_HOME"; pwd)` fi if [ -n "$JAVA_HOME" ] ; then @@ -96,13 +84,3 @@ concat_lines() { MAVEN_PROJECTBASEDIR="`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 - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -export MAVEN_PROJECTBASEDIR - diff --git a/apache-maven/src/assembly/shared/mvnlauncher b/apache-maven/src/assembly/shared/mvnlauncher index 943239b901..c523a1ddff 100644 --- a/apache-maven/src/assembly/shared/mvnlauncher +++ b/apache-maven/src/assembly/shared/mvnlauncher @@ -1,3 +1,3 @@ -LAUNCHER_JAR=`echo "${MAVEN_HOME}"/boot/plexus-classworlds-*.jar` +LAUNCHER_JAR=`echo "$MAVEN_HOME"/boot/plexus-classworlds-*.jar` MAVEN_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher diff --git a/apache-maven/src/assembly/shared/run b/apache-maven/src/assembly/shared/run index 7e8d72a44c..676bfdd9e3 100755 --- a/apache-maven/src/assembly/shared/run +++ b/apache-maven/src/assembly/shared/run @@ -1,20 +1,18 @@ -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - [ -n "$MAVEN_HOME" ] && - MAVEN_HOME=`cygpath --path --windows "$MAVEN_HOME"` +# For Cygwin and MinGW, switch paths to Windows format before running java(1) command +if $cygwin || $mingw ; then [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$LAUNCHER_JAR" ] && - LAUNCHER_JAR=`cygpath --path --windows "$LAUNCHER_JAR"` + JAVA_HOME=`cygpath --windows "$JAVA_HOME"` + LAUNCHER_JAR=`cygpath --windows "$LAUNCHER_JAR"` + CLASSWORLDS_CONF=`cygpath --windows "$CLASSWORLDS_CONF"` + MAVEN_HOME=`cygpath --windows "$MAVEN_HOME"` + MAVEN_PROJECTBASEDIR=`cygpath --windows "$MAVEN_PROJECTBASEDIR"` fi exec "$JAVACMD" \ $MAVEN_OPTS \ $MAVEN_DEBUG_OPTS \ - -classpath "${LAUNCHER_JAR}" \ + -classpath "$LAUNCHER_JAR" \ "-Dclassworlds.conf=$CLASSWORLDS_CONF" \ "-Dmaven.home=$MAVEN_HOME" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dmaven.multiModuleProjectDirectory=$MAVEN_PROJECTBASEDIR" \ $MAVEN_LAUNCHER "$@" diff --git a/apache-maven/src/assembly/shared/validate b/apache-maven/src/assembly/shared/validate index 20603f1a99..0d22a8b21a 100644 --- a/apache-maven/src/assembly/shared/validate +++ b/apache-maven/src/assembly/shared/validate @@ -51,4 +51,3 @@ case "`uname`" in MINGW*) mingw=true;; esac -