fix(jandex): register the index as a sourceSet output directory#191
Merged
Conversation
The plugin wrote the Jandex index into sourceSet.output.resourcesDir and relied on per-task dependsOn wiring so that consumers would run after the copy. That wiring was broad for the main sourceSet but covered only the jar and javadoc tasks for non-main sourceSets, so other consumers of the output -- the JMH bytecode generator, checkstyle, forbidden-apis -- had no declared dependency on processXxxJandexIndex. Gradle 9 turns that implicit dependency into a build failure (see pgjdbc/pgjdbc#4010). Build the index into a dedicated directory and register it as an extra output of the sourceSet via output.dir(builtBy = processXxxJandexIndex). Gradle then wires every consumer of the output automatically, so the manual dependsOn blocks for both main and non-main sourceSets are removed. Add a Gradle 9 integration test that drives a non-main sourceSet consumer across all JandexBuildAction modes (BUILD_AND_INCLUDE, BUILD, VERIFY_ONLY, NONE) and checks the index reaches the jar only for BUILD_AND_INCLUDE. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Why
Under Gradle 9 the build fails whenever a task consumes a non-main sourceSet output without
declaring a dependency on
processXxxJandexIndex:The plugin writes the index into
sourceSet.output.resourcesDir, which makesprocessXxxJandexIndexa second producer of that directory. It then relied on per-taskdependsOnwiring so consumers run after the copy. That wiring is broad for the main sourceSet but covers only
the
jarandjavadoctasks for non-main sourceSets, so other consumers of the output — the JMHbytecode generator,
checkstyle,forbidden-apis— are left without the dependency. Gradle 9turns that implicit dependency into a hard error. Reported downstream in pgjdbc/pgjdbc#4010.
What
sourceSet.output.dir(mapOf("builtBy" to processJandexIndex), jandexResourcesDir). Gradle thenwires every consumer of
sourceSet.outputto depend onprocessXxxJandexIndexautomatically.dependsOnblocks for both the main and non-main sourceSets — they are nowredundant, and they never covered consumers the plugin did not know about.
BUILD_AND_INCLUDE, because the jar packagessourceSet.output, which now includes the registered directory.How to verify
The new
jandexDoesNotBreakNonMainSourceSetConsumerstest pins Gradle 9, drives a non-mainsourceSet consumer, and runs across every
JandexBuildActionmode (BUILD_AND_INCLUDE,BUILD,VERIFY_ONLY,NONE), asserting the consumer builds and that the index reaches the jar only forBUILD_AND_INCLUDE. Reverting theJandexPlugin.ktchange makes that test fail with theimplicit_dependencyvalidation error.