1+ configurations {
2+ tck {
3+ transitive = false
4+ }
5+ }
6+
17dependencies {
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)
12-
13- Provider<Directory > extractTarget = layout. buildDirectory. dir(' extracted-tck-classes' )
1417
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
2732tasks. withType(Test ). configureEach {
28- dependsOn(' extractTckJar' )
29- doFirst {
30- testClassesDirs + = files(layout. buildDirectory. dir(' extracted-tck-classes' ))
33+ testClassesDirs = objects. fileCollection(). from(extractTck, testClassesDirs)
34+ finalizedBy(' cleanupTckClasses' )
35+ }
36+
37+ // There is a known issue with IntelliJ that can cause it's inspection process to lock up.
38+ // this is a work around to help prevent the scenario that causes the lock up.
39+ tasks. register(' cleanupTckClasses' ) {
40+ Provider<Directory > extractDir = layout. buildDirectory. dir(' extracted-tck-classes' )
41+ doLast {
42+ extractDir. get(). asFile. deleteDir()
3143 }
3244}
0 commit comments