Fix javadoc -Werror breakage on JDK 11#2844
Closed
donald-pinckney wants to merge 1 commit intomasterfrom
Closed
Conversation
The -Werror flag for the javadoc tool was added in JDK 15 (https://bugs.openjdk.org/browse/JDK-8232513). On older JDKs javadoc rejects the flag outright, which breaks any task that invokes javadoc (javadocJar, and therefore publishToSonatype / publishToMavenLocal) when Gradle is running on JDK 11. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Superseded by #2845. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Building javadoc (and therefore
javadocJar,publishToSonatype,publishToMavenLocal) fails on JDK 11 with:Reproducer from the root of the repo, running Gradle on JDK 11:
Every module's javadoc task rejects
-Werror, so nothing can publish. This blocks the JDK-11publish-snapshotandprepare-releaseworkflows.Cause
gradle/java.gradleunconditionally passes-Werrorto the javadoc tool. That flag was added tojavadocin JDK 15 (JDK-8232513); JDK 11'sjavadocdoesn't know it and errors.The unconditional option was added in #2822 ("Claude fix all docstring problems & add check to CI"). That PR was developed against JDK 17+ (the
javadocCI job already runs on JDK 23), so the incompatibility with the publish job's JDK 11 was not caught.Fix
Gate the
addBooleanOption('Werror', true)call onJavaVersion.current().isCompatibleWith(VERSION_15). No change on JDK 15+ (the current javadoc CI job, and any future publish job running on a newer JDK); on JDK 11 the flag is simply omitted so the tool accepts the invocation.Other
-Werroruses in the file (compileJava/compileTestJava) are forjavac, which has supported-Werrorsince Java 5 — no change needed there.Verification
Re-ran the reproducer after the fix:
🤖 Generated with Claude Code