Skip to content

Fix: Maven wrapper script quoting bug prevents Java fallback detection #187

@coderabbitai

Description

@coderabbitai

Bug Description

In the Maven wrapper script (mvnw), there's a bug where single quotes around shell built-ins prevent Java detection from working properly.

The following code in mvnw:

JAVACMD="$(
  'set' +e
  'unset' -f command 2>/dev/null
  'command' -v java
)" || :
JAVACCMD="$(
  'set' +e
  'unset' -f command 2>/dev/null
  'command' -v javac
)" || :

Should be fixed by removing the single quotes:

JAVACMD="$(
  set +e
  unset -f command 2>/dev/null
  command -v java
)" || :
JAVACCMD="$(
  set +e
  unset -f command 2>/dev/null
  command -v javac
)" || :

Impact

With the quotes, the shell literally looks for executables called set, unset, and command, which do not exist. This causes the command substitution to fail and JAVACMD/JAVACCMD remain empty. As a consequence, the Java-based download fallback will never be selected even when wget/curl are missing.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions