Skip to content

fix(jandex): register the index as a sourceSet output directory#191

Merged
vlsi merged 1 commit into
masterfrom
fix/jandex-nonmain-output-dependency
Jun 22, 2026
Merged

fix(jandex): register the index as a sourceSet output directory#191
vlsi merged 1 commit into
masterfrom
fix/jandex-nonmain-output-dependency

Conversation

@vlsi

@vlsi vlsi commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Why

Under Gradle 9 the build fails whenever a task consumes a non-main sourceSet output without
declaring a dependency on processXxxJandexIndex:

Task ':useExtraOutput' uses this output of task ':processExtraJandexIndex' without declaring an
explicit or implicit dependency.

The plugin writes the index into sourceSet.output.resourcesDir, which makes
processXxxJandexIndex a second producer of that directory. It then relied on per-task dependsOn
wiring so consumers run after the copy. That wiring is broad for the main sourceSet but covers only
the jar and javadoc tasks for non-main sourceSets, so other consumers of the output — the JMH
bytecode generator, checkstyle, forbidden-apis — are left without the dependency. Gradle 9
turns that implicit dependency into a hard error. Reported downstream in pgjdbc/pgjdbc#4010.

What

  • Build the index into a dedicated directory and register it as an extra output of the sourceSet:
    sourceSet.output.dir(mapOf("builtBy" to processJandexIndex), jandexResourcesDir). Gradle then
    wires every consumer of sourceSet.output to depend on processXxxJandexIndex automatically.
  • Remove the manual dependsOn blocks for both the main and non-main sourceSets — they are now
    redundant, and they never covered consumers the plugin did not know about.
  • The index still reaches the jar for BUILD_AND_INCLUDE, because the jar packages
    sourceSet.output, which now includes the registered directory.

How to verify

./gradlew :plugins:jandex-plugin:test

The new jandexDoesNotBreakNonMainSourceSetConsumers test pins Gradle 9, drives a non-main
sourceSet consumer, and runs across every JandexBuildAction mode (BUILD_AND_INCLUDE, BUILD,
VERIFY_ONLY, NONE), asserting the consumer builds and that the index reaches the jar only for
BUILD_AND_INCLUDE. Reverting the JandexPlugin.kt change makes that test fail with the
implicit_dependency validation error.

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>
@vlsi vlsi added bug Something isn't working jandex-plugin labels Jun 22, 2026
@vlsi vlsi merged commit 2b3859a into master Jun 22, 2026
7 of 8 checks passed
@vlsi vlsi deleted the fix/jandex-nonmain-output-dependency branch June 22, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working jandex-plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant