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

chore: fix javadoc with Java 9 and later #262

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

hashar
Copy link
Contributor

@hashar hashar commented Jun 23, 2022

The javadoc path varies between Java 8 and 11, the Java 8 one having an
extra jre directory in the pathname:

Java 8:

$ /usr/lib/jvm/java-8-openjdk-amd64/bin/java
-XshowSettings:properties -version 2>&1|grep java.home
java.home = /usr/lib/jvm/java-8-openjdk-amd64/jre

Java 11

$ /usr/lib/jvm/java-11-openjdk-amd64/bin/java
-XshowSettings:properties -version 2>&1|grep java.home
java.home = /usr/lib/jvm/java-11-openjdk-amd64

Set javadocExecutable via Maven profiles which activate based on the JDK
version being used.

That fixes the build under Java 11 when JAVA_HOME is not set.

@CarstenWickner
Copy link
Member

Hi @hashar,

Thanks for the effort of creating the PR.
Just two questions though:

  1. Am I understanding correctly, that your fix works for Java 8 and Java 11, but not for any other Java version?
  2. You say this fixes the JavaDoc generation under JDK 11 when the JAVA_HOME environment variable is not set. But that is used in the configuration now, isn't it?
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>

Also: the GitHub Action that includes the JavaDoc generation is already running under JDK 11 and works fine.
What exactly is being fixed here then?

@hashar
Copy link
Contributor Author

hashar commented Jun 24, 2022

hi @CarstenWickner ,

My local environment is Java 11 and JAVA_HOME is not set. When running the javadoc goal it complains with:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.1.0:javadoc (default-cli) on project jsonschema-generator:
An error has occurred in Javadoc report generation: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]

On GitHub I am guessing the action sets JAVA_HOME and there is no issue.

The reason for the error I encounter is, starting with Java 9, the binaries for the JDK and the JRK are now in the same directory and the Maven plugin does not take that in account. My change only refers to Java 8 and Java 11 which are the versions shipped by Debian, but the rule should have been for 8 and 9.

Regardless, looking at the plugin code, the issue was MJAVADOC-650
solved by apache/maven-javadoc-plugin@a4aafab which has a lengthy comment properly explaining the change introduced in Java 9.

So essentially my change can be dropped and repurposed to update the Maven javadoc plugin from 3.1.0 to 3.3.0 or later.

The javadoc goal fails with Java 9 or later when JAVA_HOME is not set,
the plugin is unable to find the javadoc executable. The issue has been
solved in version 3.3.0 of the plugin:
https://issues.apache.org/jira/browse/MJAVADOC-650

Update maven-javadoc-plugin to latest release 3.4.0.
@hashar
Copy link
Contributor Author

hashar commented Jun 24, 2022

Reworked to update maven-javadoc-plugin from 3.1.0 to 3.4.0 which properly find the javadoc binary.

@hashar hashar changed the title chore: fix javadoc variance between java 8 and 11+ chore: fix javadoc with Java 9 and later Jun 24, 2022
@CarstenWickner CarstenWickner merged commit b5ab0e9 into victools:main Jun 24, 2022
@CarstenWickner
Copy link
Member

Thanks @hashar 😄

@hashar
Copy link
Contributor Author

hashar commented Jun 27, 2022

Thank you for doing the extra mile in code reviewing. Will let me update the maven-javadoc-plugin in some other code bases which used the maven profiles in order to find javadoc.

lucamilanesio pushed a commit to GerritCodeReview/modules_events-broker that referenced this pull request Oct 25, 2022
The javadoc goal fails with Java 9 or later when JAVA_HOME is not set,
the plugin is unable to find the javadoc executable. The reason is
"javadoc" has been moved.

The issue has been solved in version 3.3.0 of the plugin:

https://issues.apache.org/jira/browse/MJAVADOC-650

Update the maven-javadoc-plugin to latest release 3.4.0.

I have done a similar update at:
victools/jsonschema-generator#262

Also remove the `source=8` javadoc configuration for
https://bugs.openjdk.org/browse/JDK-8212233 The pom targets Java 11.

Change-Id: If04cbe2dbdbf9583f154f7c9e1e448e74df2c19d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants