rmannibucau commented on code in PR #476:
URL: https://github.com/apache/maven-wrapper/pull/476#discussion_r4587779574


##########
maven-wrapper-distribution/src/resources/only-mvnw:
##########
@@ -52,13 +52,19 @@ 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
+    for cmd in "$JAVACMD" "$JAVACCMD" "$JARCMD"; do
+      if [ ! -x "$cmd" ]; 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
+        echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"$cmd\" does not exist 
or is not executable." >&2

Review Comment:
   Addressed in cf703c5. JAVA_HOME validation now reports the exact failing 
path and distinguishes a missing file from a non-executable file, stopping 
after the first failure. PATH lookup reports that no executable was found for 
the specific tool, and the redundant trailing JDK error is removed. The jar 
fallback is selected only when executable.
   
   Regression tests assert exact messages, first-failure behavior, executable 
jar fallback selection, and rejection of commands outside PATH. Validation: 
clean reactor build under JDK 17 passed (34 unit tests and the 
sh_type_only-script/type_only-script integration tests); dash/bash syntax 
checks and git diff --check passed.



-- 
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]

Reply via email to