This is an automated email from the ASF dual-hosted git repository.
bmarwell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-wrapper.git
The following commit(s) were added to refs/heads/master by this push:
new dcb0652 [MWRAPPER-112] Detection of JAVA_HOME fails due to bad
quoting (#102)
dcb0652 is described below
commit dcb065270c93b5dbed54ab85f52f99b5c4a6ae45
Author: Ingo Karkat <[email protected]>
AuthorDate: Mon Feb 5 19:47:27 2024 +0100
[MWRAPPER-112] Detection of JAVA_HOME fails due to bad quoting (#102)
On a standard Ubuntu 20.04 Java installation (openjdk-17-jdk APT package,
/usr/bin/javac linked to /usr/lib/jvm/java-17-openjdk-amd64/bin/javac via the
update-alternatives system, no JAVA_HOME set), Maven Wrapper 3.2.0 prints this
warning on each invocation:
> Warning: JAVA_HOME environment variable is not set.
This is caused by excessive quoting that adds literal double quotes to the
resolution of javaHome and javaExecutable. (Some nearby invocations of "expr"
use correct quoting, but several are wrong. There might have been obscure bugs
and someone thought that more quoting is better. That code has been in the
codebase since the beginning, taken over from the gradlew wrapper (which had
the shell wrappers completely rewritten; there are no remnants of this code
found there any longer).) Wit [...]
---
maven-wrapper-distribution/src/resources/mvnw | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/maven-wrapper-distribution/src/resources/mvnw
b/maven-wrapper-distribution/src/resources/mvnw
index b68cc2b..59ebc2d 100644
--- a/maven-wrapper-distribution/src/resources/mvnw
+++ b/maven-wrapper-distribution/src/resources/mvnw
@@ -100,17 +100,17 @@ fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
- if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^
]*\)')" = "no" ]; then
+ if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')"
= "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=$(which readlink)
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
if $darwin; then
- javaHome="$(dirname "\"$javaExecutable\"")"
- javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
+ javaHome="$(dirname "$javaExecutable")"
+ javaExecutable="$(cd "$javaHome" && pwd -P)/javac"
else
- javaExecutable="$(readlink -f "\"$javaExecutable\"")"
+ javaExecutable="$(readlink -f "$javaExecutable")"
fi
- javaHome="$(dirname "\"$javaExecutable\"")"
+ javaHome="$(dirname "$javaExecutable")"
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME