From 68edd33d9858c575e4d56247ee24b24f1946bdc0 Mon Sep 17 00:00:00 2001 From: jjh75607 Date: Fri, 28 Aug 2026 10:16:17 +0900 Subject: [PATCH 1/2] Declare the jar and shadowJar dependencies of the test classpath --- gradle/shading.gradle | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gradle/shading.gradle b/gradle/shading.gradle index 88f25cc3f22..abfc8ddc73d 100644 --- a/gradle/shading.gradle +++ b/gradle/shading.gradle @@ -56,11 +56,14 @@ project.afterEvaluate { tasks.shadowJar.relocate(pkg, "org.testcontainers.shaded.${pkg}") } - // Add shaded JARs first - tasks.test.classpath = findShadedProjects(project) + // Add shaded JARs first. Wrapping the producing tasks in files() keeps their task dependencies + // on the classpath; a plain sum of outputs drops them. shadowJar clears its classifier and + // writes the same file as jar, so test has to depend on both. + def producers = findShadedProjects(project) .plus(project) - .sum { it.tasks.findByName("shadowJar").outputs.files } - .plus(sourceSets.test.runtimeClasspath) + .collectMany { [it.tasks.findByName("shadowJar"), it.tasks.findByName("jar")] } + .findAll { it != null } + tasks.test.classpath = files(producers).plus(sourceSets.test.runtimeClasspath) } static Set findShadedProjects(Project project) { From 4987d59409189782a2138d65c60ed17c1d4f9e0f Mon Sep 17 00:00:00 2001 From: jjh75607 Date: Fri, 28 Aug 2026 10:28:03 +0900 Subject: [PATCH 2/2] Wire test-scoped project dependencies into the test classpath too --- gradle/shading.gradle | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gradle/shading.gradle b/gradle/shading.gradle index abfc8ddc73d..e895072e3c8 100644 --- a/gradle/shading.gradle +++ b/gradle/shading.gradle @@ -58,9 +58,11 @@ project.afterEvaluate { // Add shaded JARs first. Wrapping the producing tasks in files() keeps their task dependencies // on the classpath; a plain sum of outputs drops them. shadowJar clears its classifier and - // writes the same file as jar, so test has to depend on both. - def producers = findShadedProjects(project) - .plus(project) + // writes the same file as jar, so test has to depend on both. Test-scoped project dependencies + // (e.g. testcontainers-jdbc-test) are shaded the same way and need the same wiring. + def testProjectDependencies = configurations.testRuntimeClasspath.allDependencies + .withType(ProjectDependency)*.dependencyProject + def producers = (findShadedProjects(project) + project + testProjectDependencies) .collectMany { [it.tasks.findByName("shadowJar"), it.tasks.findByName("jar")] } .findAll { it != null } tasks.test.classpath = files(producers).plus(sourceSets.test.runtimeClasspath)