elharo commented on code in PR #476:
URL: https://github.com/apache/maven-wrapper/pull/476#discussion_r4586247586
##########
maven-wrapper-distribution/src/resources/only-mvnw:
##########
@@ -70,9 +74,14 @@ set_java_home() {
'unset' -f command 2>/dev/null
'command' -v javac
)" || :
+ JARCMD="$(
+ 'set' +e
+ 'unset' -f command 2>/dev/null
+ 'command' -v jar
+ )" || :
- if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
- echo "The java/javac command does not exist in PATH nor is JAVA_HOME
set, so mvnw cannot run." >&2
+ if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ] || [ ! -x
"${JARCMD-}" ]; then
+ echo "The java/javac/jar command does not exist in PATH nor is JAVA_HOME
set, so mvnw cannot run." >&2
Review Comment:
again, be specific
##########
maven-wrapper-distribution/src/resources/only-mvnw:
##########
@@ -41,7 +41,7 @@ CYGWIN* | MINGW*)
;;
esac
-# set JAVACMD and JAVACCMD
+# set JAVACMD, JAVACCMD and JARCMD
Review Comment:
comma after JAVACCMD
##########
maven-wrapper-distribution/src/resources/only-mvnw:
##########
@@ -52,12 +52,16 @@ set_java_home() {
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACCMD="$JAVA_HOME/bin/javac"
+ fi
+ JARCMD="$JAVA_HOME/bin/jar"
+ if [ ! -x "$JARCMD" ]; then
+ JARCMD="$JAVA_HOME/jre/bin/jar"
+ fi
- if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
- echo "The JAVA_HOME environment variable is not defined correctly, so
mvnw cannot run." >&2
- echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\"
or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
- return 1
- fi
+ if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ] || [ ! -x "$JARCMD" ]; then
+ echo "The JAVA_HOME environment variable is not defined correctly, so
mvnw cannot run." >&2
+ echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\",
\"\$JAVA_HOME/bin/javac\" or \"\$JAVA_HOME/bin/jar\" does not exist." >&2
Review Comment:
here we should be specific. Which ones do not exist? Don't make the user
guess
##########
maven-wrapper-distribution/src/resources/only-mvnw:
##########
@@ -170,20 +179,18 @@ fi
mkdir -p -- "${MAVEN_HOME%/*}"
-# select .zip or .tar.gz
-if ! command -v unzip >/dev/null; then
- distributionUrl="${distributionUrl%.zip}.tar.gz"
- distributionUrlName="${distributionUrl##*/}"
-fi
+# jar from the JDK is required to extract the distribution; resolve the JDK
+# tools here so they are guaranteed even when wget/curl are used for download
Review Comment:
I'm not sure what "even when wget/curl are used for download" has to do with
anything
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]