Parameterize kotlin test infra on CI (#1407)

This commit is contained in:
Zac Sweers
2021-10-25 11:00:56 -04:00
committed by GitHub
parent 7dd3b39376
commit 313683fa98
17 changed files with 328 additions and 183 deletions

View File

@@ -14,6 +14,9 @@
* limitations under the License.
*/
import Build_gradle.TestMode.KAPT
import Build_gradle.TestMode.KSP
import Build_gradle.TestMode.REFLECT
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
@@ -22,11 +25,24 @@ plugins {
id("com.google.devtools.ksp") apply false
}
val useKsp = hasProperty("useKsp")
if (useKsp) {
apply(plugin = "com.google.devtools.ksp")
} else {
apply(plugin = "org.jetbrains.kotlin.kapt")
enum class TestMode {
REFLECT, KAPT, KSP
}
val testMode = findProperty("kotlinTestMode")?.toString()
?.let(TestMode::valueOf)
?: REFLECT
when (testMode) {
REFLECT -> {
// Do nothing!
}
KAPT -> {
apply(plugin = "org.jetbrains.kotlin.kapt")
}
KSP -> {
apply(plugin = "com.google.devtools.ksp")
}
}
tasks.withType<Test>().configureEach {
@@ -48,10 +64,16 @@ tasks.withType<KotlinCompile>().configureEach {
}
dependencies {
if (useKsp) {
"kspTest"(project(":kotlin:codegen"))
} else {
"kaptTest"(project(":kotlin:codegen"))
when (testMode) {
REFLECT -> {
// Do nothing
}
KAPT -> {
"kaptTest"(project(":kotlin:codegen"))
}
KSP -> {
"kspTest"(project(":kotlin:codegen"))
}
}
testImplementation(project(":moshi"))
testImplementation(project(":kotlin:reflect"))