1
+ @file:Suppress(" UnstableApiUsage" )
2
+
1
3
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2
4
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
3
5
@@ -44,26 +46,6 @@ spotless {
44
46
}
45
47
}
46
48
47
- val intiTest: SourceSet by sourceSets.creating
48
- val intiTestImplementation: Configuration by configurations.getting {
49
- extendsFrom(configurations.testImplementation.get())
50
- }
51
- val intiTestRuntimeOnly: Configuration by configurations.getting {
52
- extendsFrom(configurations.testRuntimeOnly.get())
53
- }
54
-
55
- val funcTest: SourceSet by sourceSets.creating
56
- val funcTestImplementation: Configuration by configurations.getting {
57
- extendsFrom(configurations.testImplementation.get())
58
- }
59
- val funcTestRuntimeOnly: Configuration by configurations.getting {
60
- extendsFrom(configurations.testRuntimeOnly.get())
61
- }
62
-
63
- gradlePlugin {
64
- testSourceSets.add(funcTest)
65
- }
66
-
67
49
dependencies {
68
50
implementation(libs.apache.ant)
69
51
implementation(libs.apache.commonsIo)
@@ -74,61 +56,81 @@ dependencies {
74
56
implementation(libs.plexus.utils)
75
57
implementation(libs.plexus.xml)
76
58
77
- testImplementation(platform(libs.junit.bom))
78
- testImplementation(libs.junit.jupiter)
79
- testImplementation(libs.assertk)
80
- testImplementation(libs.xmlunit)
81
- testRuntimeOnly(libs.junit.platformLauncher)
82
-
83
- funcTestImplementation(sourceSets.main.get().output)
84
- funcTestImplementation(libs.apache.maven.modelBuilder)
85
- funcTestImplementation(libs.moshi)
86
- funcTestImplementation(libs.moshi.kotlin)
87
-
88
59
lintChecks(libs.androidx.gradlePluginLints)
89
60
}
90
61
91
- val integrationTest by tasks.registering(Test ::class ) {
92
- description = " Runs the integration tests."
93
- group = LifecycleBasePlugin .VERIFICATION_GROUP
94
- testClassesDirs = intiTest.output.classesDirs
95
- classpath = intiTest.runtimeClasspath
62
+ testing.suites {
63
+ getByName<JvmTestSuite >(" test" ) {
64
+ dependencies {
65
+ implementation(libs.xmlunit)
66
+ }
67
+ }
68
+ register<JvmTestSuite >(" integrationTest" ) {
69
+ testType = TestSuiteType .INTEGRATION_TEST
70
+ targets.configureEach {
71
+ testTask {
72
+ val docsDir = file(" src/docs" )
73
+ // Add src/docs as an input directory to trigger ManualCodeSnippetTests re-run on changes.
74
+ inputs.dir(docsDir)
75
+ systemProperty(" DOCS_DIR" , docsDir.absolutePath)
76
+ }
77
+ }
78
+ }
79
+ register<JvmTestSuite >(" functionalTest" ) {
80
+ testType = TestSuiteType .FUNCTIONAL_TEST
81
+ targets.configureEach {
82
+ testTask {
83
+ // Required to enable `IssueExtension` for all tests.
84
+ systemProperty(" junit.jupiter.extensions.autodetection.enabled" , true )
85
+
86
+ // Required to test configuration cache in tests when using withDebug()
87
+ // https://github.com/gradle/gradle/issues/22765#issuecomment-1339427241
88
+ jvmArgs(
89
+ " --add-opens" ,
90
+ " java.base/java.util=ALL-UNNAMED" ,
91
+ " --add-opens" ,
92
+ " java.base/java.util.concurrent.atomic=ALL-UNNAMED" ,
93
+ " --add-opens" ,
94
+ " java.base/java.lang.invoke=ALL-UNNAMED" ,
95
+ " --add-opens" ,
96
+ " java.base/java.net=ALL-UNNAMED" ,
97
+ )
98
+ }
99
+ }
100
+ dependencies {
101
+ // Seems we can't ref project() here due to some limitations of rootProject.
102
+ implementation(sourceSets.main.get().output)
103
+ implementation(libs.apache.ant)
104
+ implementation(libs.apache.maven.modelBuilder)
105
+ implementation(libs.moshi)
106
+ implementation(libs.moshi.kotlin)
107
+ }
108
+ }
96
109
97
- val docsDir = file(" src/docs" )
98
- // Add src/docs as an input directory to trigger ManualCodeSnippetTests re-run on changes.
99
- inputs.dir(docsDir)
100
- systemProperty(" DOCS_DIR" , docsDir.absolutePath)
110
+ withType<JvmTestSuite >().configureEach {
111
+ useJUnitJupiter(libs.junit.bom.map { requireNotNull(it.version) })
112
+ dependencies {
113
+ implementation(libs.assertk)
114
+ }
115
+ targets.configureEach {
116
+ testTask {
117
+ maxParallelForks = Runtime .getRuntime().availableProcessors()
118
+ }
119
+ }
120
+ }
101
121
}
102
122
103
- val functionalTest by tasks.registering(Test ::class ) {
104
- description = " Runs the functional tests."
105
- group = LifecycleBasePlugin .VERIFICATION_GROUP
106
- testClassesDirs = funcTest.output.classesDirs
107
- classpath = funcTest.runtimeClasspath
108
-
109
- // Required to enable `IssueExtension` for all tests.
110
- systemProperty(" junit.jupiter.extensions.autodetection.enabled" , true )
123
+ gradlePlugin {
124
+ testSourceSets(
125
+ sourceSets[" functionalTest" ],
126
+ sourceSets[" integrationTest" ],
127
+ )
111
128
}
112
129
113
130
tasks.check {
114
- dependsOn(integrationTest, functionalTest)
115
- }
116
-
117
- tasks.withType<Test >().configureEach {
118
- useJUnitPlatform()
119
- maxParallelForks = Runtime .getRuntime().availableProcessors()
120
-
121
- // Required to test configuration cache in tests when using withDebug()
122
- // https://github.com/gradle/gradle/issues/22765#issuecomment-1339427241
123
- jvmArgs(
124
- " --add-opens" ,
125
- " java.base/java.util=ALL-UNNAMED" ,
126
- " --add-opens" ,
127
- " java.base/java.util.concurrent.atomic=ALL-UNNAMED" ,
128
- " --add-opens" ,
129
- " java.base/java.lang.invoke=ALL-UNNAMED" ,
130
- " --add-opens" ,
131
- " java.base/java.net=ALL-UNNAMED" ,
131
+ dependsOn(
132
+ testing.suites.named(" integrationTest" ),
133
+ testing.suites.named(" functionalTest" ),
132
134
)
133
135
}
134
136
0 commit comments