From b4168e41c44482f8a428cc865598b0140ed0696e Mon Sep 17 00:00:00 2001 From: Patrick Neulichedl Date: Mon, 2 Dec 2024 06:41:57 +0100 Subject: [PATCH 1/3] fix(gradle): jarFileTest caching This was simply a call to project.file which has no effect on this task. The inputs prefix was not added when this was added with commit: b5331f48342521b7c0b1f27135b275835a04c44d --- core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/build.gradle b/core/build.gradle index a4e57d9473b..f32c8599aa9 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -33,7 +33,7 @@ task jarFileTest(type: Test) { testClassesDirs = sourceSets.jarFileTest.output.classesDirs classpath = sourceSets.jarFileTest.runtimeClasspath - file(shadowJar.outputs.files.singleFile) // input for correct caching + inputs.file(shadowJar.outputs.files.singleFile) // input for correct caching systemProperty("jarFile", shadowJar.outputs.files.singleFile) dependsOn(shadowJar) From 6354fe3926a2cd5875fd23522d73be4f5ace95ad Mon Sep 17 00:00:00 2001 From: Patrick Neulichedl Date: Mon, 2 Dec 2024 07:16:09 +0100 Subject: [PATCH 2/3] chore(gradle): Simplify jarFileTest setup When using gradle types as inputs task dependencies are tracked automatically. task.outputs returns a gradle type while singleFile returns a plain java File. --- core/build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index f32c8599aa9..9fe0c629eeb 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -33,10 +33,8 @@ task jarFileTest(type: Test) { testClassesDirs = sourceSets.jarFileTest.output.classesDirs classpath = sourceSets.jarFileTest.runtimeClasspath - inputs.file(shadowJar.outputs.files.singleFile) // input for correct caching + inputs.files(shadowJar.outputs) // input for correct caching systemProperty("jarFile", shadowJar.outputs.files.singleFile) - - dependsOn(shadowJar) } project.tasks.check.dependsOn(jarFileTest) From ebdbfc9b36ebb4fd50f91a77d179be190c566c53 Mon Sep 17 00:00:00 2001 From: Patrick Neulichedl Date: Mon, 2 Dec 2024 07:21:46 +0100 Subject: [PATCH 3/3] chore(gradle): Use JvmTestSuites for jarFileTest setup This is the new and recommended way and also how it is done for the unit-test setup internally in gradle by now. --- core/build.gradle | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index 9fe0c629eeb..467d203b515 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -2,14 +2,8 @@ apply plugin: 'com.gradleup.shadow' description = "Testcontainers Core" -sourceSets { - jarFileTest -} - test.maxParallelForks = 4 -idea.module.testSourceDirs += sourceSets.jarFileTest.allSource.srcDirs - jar { manifest { attributes('Implementation-Version': project.getProperty("version")) @@ -29,15 +23,6 @@ shadowJar { ].each { exclude(it) } } -task jarFileTest(type: Test) { - testClassesDirs = sourceSets.jarFileTest.output.classesDirs - classpath = sourceSets.jarFileTest.runtimeClasspath - - inputs.files(shadowJar.outputs) // input for correct caching - systemProperty("jarFile", shadowJar.outputs.files.singleFile) -} -project.tasks.check.dependsOn(jarFileTest) - tasks.japicmp { packageExcludes = [ "com.github.dockerjava.*", @@ -120,12 +105,6 @@ dependencies { testImplementation 'org.assertj:assertj-core:3.26.3' testImplementation 'io.rest-assured:rest-assured:5.5.0' - - jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}" - jarFileTestAnnotationProcessor "org.projectlombok:lombok:${lombok.version}" - jarFileTestImplementation 'junit:junit:4.13.2' - jarFileTestImplementation 'org.assertj:assertj-core:3.26.3' - jarFileTestImplementation 'org.ow2.asm:asm-debug-all:5.2' } tasks.generatePomFileForMavenJavaPublication.finalizedBy( @@ -134,3 +113,27 @@ tasks.generatePomFileForMavenJavaPublication.finalizedBy( ] } ) + +testing { + suites { + jarFileTest(JvmTestSuite) { + dependencies { + compileOnly("org.projectlombok:lombok:${lombok.version}") + annotationProcessor("org.projectlombok:lombok:${lombok.version}") + implementation('junit:junit:4.13.2') + implementation('org.assertj:assertj-core:3.26.3') + implementation('org.ow2.asm:asm-debug-all:5.2') + } + + targets { + all { + testTask.configure { + inputs.files(shadowJar.outputs) // input for correct caching + systemProperty("jarFile", shadowJar.outputs.files.singleFile) + } + } + } + } + } +} +project.tasks.check.dependsOn(jarFileTest)