Skip to content

Commit f94417c

Browse files

35 files changed

+68
-68
lines changed

build.gradle.kts

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("UnstableApiUsage")
2+
13
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
24
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
35

@@ -44,26 +46,6 @@ spotless {
4446
}
4547
}
4648

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-
6749
dependencies {
6850
implementation(libs.apache.ant)
6951
implementation(libs.apache.commonsIo)
@@ -74,61 +56,81 @@ dependencies {
7456
implementation(libs.plexus.utils)
7557
implementation(libs.plexus.xml)
7658

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-
8859
lintChecks(libs.androidx.gradlePluginLints)
8960
}
9061

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+
}
96109

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+
}
101121
}
102122

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+
)
111128
}
112129

113130
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"),
132134
)
133135
}
134136

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ androidx-gradlePluginLints = "androidx.lint:lint-gradle:1.0.0-alpha03"
2626
ktlint = "com.pinterest.ktlint:ktlint-cli:1.5.0"
2727

2828
junit-bom = "org.junit:junit-bom:5.11.4"
29-
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
30-
junit-platformLauncher = { module = "org.junit.platform:junit-platform-launcher" }
3129
assertk = "com.willowtreeapps.assertk:assertk:0.28.1"
3230

3331
[plugins]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)