Skip to content

Commit bc8a1ef

Browse files
committed
refactor: improve the tck process to be lazy evaluated
1 parent 89560ea commit bc8a1ef

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

gradle/tck-config.gradle

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1+
configurations {
2+
tck {
3+
transitive = false
4+
}
5+
}
6+
17
dependencies {
28
if (!project.hasProperty('includeBaseTckClass') || project.findProperty('includeBaseTckClass')) {
39
testImplementation project(':grails-datastore-gorm-tck-base')
410
}
11+
// So we can easily extract the compiled classes
12+
tck project(':grails-datastore-gorm-tck')
13+
// Because we reference tests in the SimpleTestSuite to be able to run them in the IDE,
14+
// the tests need explicitly added to the classpath as well
515
testImplementation project(':grails-datastore-gorm-tck')
616
testImplementation project(':grails-datastore-gorm-tck-domains')
7-
}
8-
9-
// TODO: gradle will happily put the jar file on the classpath, but junit won't find the tests. Dynamic test discovery also won't find them.
10-
tasks.register('extractTckJar', Copy) {
11-
dependsOn(configurations.testRuntimeClasspath)
1217

13-
Provider<Directory> extractTarget = layout.buildDirectory.dir('extracted-tck-classes')
14-
15-
doFirst {
16-
extractTarget.get().asFile.deleteDir()
18+
runtimeOnly 'org.apache.groovy:groovy-dateutil', {
19+
// Groovy Date Utils Extensions are used in the tests
1720
}
21+
}
1822

19-
outputs.dir(extractTarget)
20-
File tckJar = configurations.testRuntimeClasspath.resolve().find { it.name.startsWith("grails-datastore-gorm-tck-${projectVersion}") }
21-
if (tckJar) {
22-
from(zipTree(tckJar))
23-
into(extractTarget)
24-
}
23+
// TODO: gradle will happily put the jar file on the classpath, but junit won't find the tests.
24+
// Dynamic test discovery also won't find them so extract the class files to force junit to work.
25+
TaskProvider<Sync> extractTck = tasks.register('extractTckJar', Sync) {
26+
inputs.files(configurations.tck)
27+
28+
from { zipTree(configurations.tck.singleFile) }
29+
into(layout.buildDirectory.dir('extracted-tck-classes'))
2530
}
2631

2732
tasks.withType(Test).configureEach {
28-
dependsOn('extractTckJar')
29-
doFirst {
30-
testClassesDirs += files(layout.buildDirectory.dir('extracted-tck-classes'))
31-
}
33+
testClassesDirs += objects.fileCollection().from(extractTck)
3234
}

0 commit comments

Comments
 (0)