Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MWRAPPER-112] Detection of JAVA_HOME fails due to bad quoting #102

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

inkarkat
Copy link
Contributor

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).) With the literal quotes, the file system lookup fails to resolve the directory, and the auto-detection of JAVA_HOME fails, causing that warning.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MWRAPPER-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MWRAPPER-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@dtrts
Copy link

dtrts commented Jan 30, 2024

+1

I've also ran into this error. It looks like it was introduced in this PR potentially as a misinterpretation of the shell check rules.

@bmarwell bmarwell self-requested a review February 5, 2024 08:13
@bmarwell
Copy link
Contributor

bmarwell commented Feb 5, 2024

Thanks! Will rebase and take a look.

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).) With the literal quotes, the file system lookup fails to resolve the directory, and the auto-detection of JAVA_HOME fails, causing that warning.
@bmarwell
Copy link
Contributor

bmarwell commented Feb 5, 2024

@inkarkat can you please sign an ICLA? => https://www.apache.org/licenses/contributor-agreements.html

All contributors of ideas, code, or documentation to any Apache projects must complete, sign, and submit via email an Individual Contributor License Agreement (ICLA).

@inkarkat
Copy link
Contributor Author

inkarkat commented Feb 5, 2024

Alright, I've sent the signed ICLA to the secretary email address (I was under the impression that this change of < 20 lines and basically just deletions didn't require one).

May I also draw your attention to #106 - the second PR from me that fixes another issue in the wrapper scripts?! I've just freshly rebased that one.

@bmarwell
Copy link
Contributor

bmarwell commented Feb 5, 2024

I was just pointed to a mail that since GitHub, ICLAs are only required for committers. Sorry, I didn't know better (but now I do).

@bmarwell bmarwell merged commit dcb0652 into apache:master Feb 5, 2024
20 checks passed
@inkarkat inkarkat deleted the fix/quoting branch February 6, 2024 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants