fix(build): declare explicit task dependencies for Gradle 8 strict validation#11836
Closed
kiview wants to merge 1 commit into
Closed
fix(build): declare explicit task dependencies for Gradle 8 strict validation#11836kiview wants to merge 1 commit into
kiview wants to merge 1 commit into
Conversation
…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).
Member
Author
|
Bad AI, sorry. |
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.
Problem
./gradlew buildfails with 16 tasks reporting implicit dependency errors under Gradle 8's stricter task dependency validation:Three groups of modules are affected:
test-support— ownshadowJar/jaroutput placed on test classpath withouttest.dependsOntestImplementation project(':testcontainers-jdbc-test')resolves to theshadowJaroutput but no dependency was declared from the consuming module'stesttaskdocs/examplesredis tests (junit5 + spock) — same issue as test-supportAll root cause is in
gradle/shading.gradle, which is applied to all subprojects via rootbuild.gradle. ItsafterEvaluateblock manually buildstasks.test.classpathwith shadow JAR outputs but never declares those tasks as dependencies oftest.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):shadedProjects.each— declarestest.dependsOn(shadowJar)andtest.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.configurations.testImplementation.dependencies.withType(ProjectDependency).each— declarestest.dependsOn(shadowJar)for eachtestImplementationproject 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-runfor all 16 previously failing tasks shows no implicit dependency errorsjar,shadowJar, and:testcontainers-jdbc-test:shadowJarall appear before their respectivetesttasks in the execution graph