Skip to content

Commit ebdbfc9

Browse files
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.
1 parent 6354fe3 commit ebdbfc9

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

core/build.gradle

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ apply plugin: 'com.gradleup.shadow'
22

33
description = "Testcontainers Core"
44

5-
sourceSets {
6-
jarFileTest
7-
}
8-
95
test.maxParallelForks = 4
106

11-
idea.module.testSourceDirs += sourceSets.jarFileTest.allSource.srcDirs
12-
137
jar {
148
manifest {
159
attributes('Implementation-Version': project.getProperty("version"))
@@ -29,15 +23,6 @@ shadowJar {
2923
].each { exclude(it) }
3024
}
3125

32-
task jarFileTest(type: Test) {
33-
testClassesDirs = sourceSets.jarFileTest.output.classesDirs
34-
classpath = sourceSets.jarFileTest.runtimeClasspath
35-
36-
inputs.files(shadowJar.outputs) // input for correct caching
37-
systemProperty("jarFile", shadowJar.outputs.files.singleFile)
38-
}
39-
project.tasks.check.dependsOn(jarFileTest)
40-
4126
tasks.japicmp {
4227
packageExcludes = [
4328
"com.github.dockerjava.*",
@@ -120,12 +105,6 @@ dependencies {
120105

121106
testImplementation 'org.assertj:assertj-core:3.26.3'
122107
testImplementation 'io.rest-assured:rest-assured:5.5.0'
123-
124-
jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}"
125-
jarFileTestAnnotationProcessor "org.projectlombok:lombok:${lombok.version}"
126-
jarFileTestImplementation 'junit:junit:4.13.2'
127-
jarFileTestImplementation 'org.assertj:assertj-core:3.26.3'
128-
jarFileTestImplementation 'org.ow2.asm:asm-debug-all:5.2'
129108
}
130109

131110
tasks.generatePomFileForMavenJavaPublication.finalizedBy(
@@ -134,3 +113,27 @@ tasks.generatePomFileForMavenJavaPublication.finalizedBy(
134113
]
135114
}
136115
)
116+
117+
testing {
118+
suites {
119+
jarFileTest(JvmTestSuite) {
120+
dependencies {
121+
compileOnly("org.projectlombok:lombok:${lombok.version}")
122+
annotationProcessor("org.projectlombok:lombok:${lombok.version}")
123+
implementation('junit:junit:4.13.2')
124+
implementation('org.assertj:assertj-core:3.26.3')
125+
implementation('org.ow2.asm:asm-debug-all:5.2')
126+
}
127+
128+
targets {
129+
all {
130+
testTask.configure {
131+
inputs.files(shadowJar.outputs) // input for correct caching
132+
systemProperty("jarFile", shadowJar.outputs.files.singleFile)
133+
}
134+
}
135+
}
136+
}
137+
}
138+
}
139+
project.tasks.check.dependsOn(jarFileTest)

0 commit comments

Comments
 (0)