You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/05/09 17:01:20 UTC
[maven] branch MNG-5937 updated: sync find_maven_basedir with mvn
script
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-5937
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/MNG-5937 by this push:
new 74a230c sync find_maven_basedir with mvn script
74a230c is described below
commit 74a230c3bb41f364542e067b705bf3a6c4b5dcb9
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat May 9 19:01:09 2020 +0200
sync find_maven_basedir with mvn script
---
maven-wrapper/src/assembly/shared/mvnw | 67 +++++++++++++++++++++-------------
1 file changed, 41 insertions(+), 26 deletions(-)
diff --git a/maven-wrapper/src/assembly/shared/mvnw b/maven-wrapper/src/assembly/shared/mvnw
index 77aae5d..97b8c00 100755
--- a/maven-wrapper/src/assembly/shared/mvnw
+++ b/maven-wrapper/src/assembly/shared/mvnw
@@ -165,27 +165,48 @@ CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
-
- if [ -z "$1" ]
- then
- echo "Path not specified to find_maven_basedir"
- return 1
- fi
-
- basedir="$1"
- wdir="$1"
+(
+ basedir=`find_file_argument_basedir "$@"`
+ wdir="${basedir}"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
- # workaround for JBEAP-8937 (on Solaris 10/Sparc)
- if [ -d "${wdir}" ]; then
- wdir=`cd "$wdir/.."; pwd`
+ wdir=`cd "$wdir/.."; pwd`
+ done
+ echo "${basedir}"
+)
+}
+
+find_file_argument_basedir() {
+(
+ basedir=`pwd`
+
+ found_file_switch=0
+ for arg in "$@"; do
+ if [ ${found_file_switch} -eq 1 ]; then
+ if [ -d "${arg}" ]; then
+ basedir=`cd "${arg}" && pwd -P`
+ elif [ -f "${arg}" ]; then
+ basedir=`dirname "${arg}"`
+ basedir=`cd "${basedir}" && pwd -P`
+ if [ ! -d "${basedir}" ]; then
+ echo "Directory ${basedir} extracted from the -f/--file command-line argument ${arg} does not exist" >&2
+ exit 1
+ fi
+ else
+ echo "POM file ${arg} specified with the -f/--file command line argument does not exist" >&2
+ exit 1
+ fi
+ break
+ fi
+ if [ "$arg" = "-f" -o "$arg" = "--file" ]; then
+ found_file_switch=1
fi
- # end of workaround
done
echo "${basedir}"
+)
}
# concatenates all lines of a file
@@ -279,24 +300,18 @@ fi
# End of extension
##########################################################################################
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
-if [ "$MVNW_VERBOSE" = true ]; then
- echo $MAVEN_PROJECTBASEDIR
-fi
+MAVEN_PROJECTBASEDIR="${MAVEN_BASEDIR:-`find_maven_basedir "$@"`}"
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+# 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"`
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
+export MAVEN_PROJECTBASEDIR
+
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"