Skip to content

fix(build): declare explicit task dependencies for Gradle 8 strict validation#11836

Closed
kiview wants to merge 1 commit into
mainfrom
fix/gradle8-implicit-dependencies
Closed

fix(build): declare explicit task dependencies for Gradle 8 strict validation#11836
kiview wants to merge 1 commit into
mainfrom
fix/gradle8-implicit-dependencies

Conversation

@kiview
Copy link
Copy Markdown
Member

@kiview kiview commented Jun 8, 2026

Problem

./gradlew build fails with 16 tasks reporting implicit dependency errors under Gradle 8's stricter task dependency validation:

Task uses output of another task without declaring an explicit or implicit dependency

Three groups of modules are affected:

  • test-support — own shadowJar/jar output placed on test classpath without test.dependsOn
  • 13 JDBC modules (mariadb, mssqlserver, mysql, oceanbase, oracle-free, oracle-xe, postgresql, presto, questdb, tidb, timeplus, trino, yugabytedb) — testImplementation project(':testcontainers-jdbc-test') resolves to the shadowJar output but no dependency was declared from the consuming module's test task
  • docs/examples redis tests (junit5 + spock) — same issue as test-support

All root cause is in gradle/shading.gradle, which is applied to all subprojects via root build.gradle. Its afterEvaluate block manually builds tasks.test.classpath with shadow JAR outputs but never declares those tasks as dependencies of test.

Note: 5 additional JDBC modules (clickhouse, cockroachdb, cratedb, databend, db2) have the same underlying issue but their tests were served from cache — they are also fixed by this change.

Fix

Two new blocks added to gradle/shading.gradle (26 lines):

  1. shadedProjects.each — declares test.dependsOn(shadowJar) and test.dependsOn(jar) for every project in the shaded chain, including the project itself. Both are required because non-published modules write both tasks to the same output filename.

  2. configurations.testImplementation.dependencies.withType(ProjectDependency).each — declares test.dependsOn(shadowJar) for each testImplementation project dependency whose primary artifact is the shadow JAR. This covers all 13 JDBC modules and any future modules added with the same pattern.

Validation

  • ./gradlew --dry-run for all 16 previously failing tasks shows no implicit dependency errors
  • jar, shadowJar, and :testcontainers-jdbc-test:shadowJar all appear before their respective test tasks in the execution graph

…ibility

Gradle 8 enforces strict implicit dependency validation: tasks that use
the output of another task must declare an explicit dependency on it.
Three groups of modules were failing:

1. test-support: test used output of jar without dependency
2. 13 JDBC modules (mariadb, mssqlserver, mysql, oceanbase, oracle-free,
   oracle-xe, postgresql, presto, questdb, tidb, timeplus, trino,
   yugabytedb): test used output of :testcontainers-jdbc-test:shadowJar
   without dependency
3. docs/examples junit5/redis and spock/redis: test used output of jar
   without dependency

Root cause: shading.gradle modifies tasks.test.classpath in afterEvaluate
to include shadowJar outputs, but never declared the corresponding
task dependencies.

Fix: after computing shadedProjects and setting test.classpath, explicitly
call test.dependsOn for each project's jar and shadowJar tasks (both are
needed for non-published modules where both tasks write the same filename),
and also for shadowJar of testImplementation project dependencies whose
primary artifact is produced by shadowJar (classifier=null).
@kiview kiview requested a review from a team as a code owner June 8, 2026 08:43
@kiview
Copy link
Copy Markdown
Member Author

kiview commented Jun 8, 2026

Bad AI, sorry.

@kiview kiview closed this Jun 8, 2026
@eddumelendez eddumelendez deleted the fix/gradle8-implicit-dependencies branch June 8, 2026 16:56
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.

1 participant