mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-22 13:46:13 +08:00
Buildscript: Fix test artifacts included in main sourceset
This commit is contained in:
parent
d01f71ff8b
commit
a143340141
@ -70,28 +70,43 @@ fun Project.configureKotlinTestSettings() {
|
|||||||
tasks.withType(Test::class) {
|
tasks.withType(Test::class) {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
val b = "Auto-set for project '${project.path}'. (configureKotlinTestSettings)"
|
||||||
when {
|
when {
|
||||||
isKotlinJvmProject -> {
|
isKotlinJvmProject -> {
|
||||||
dependencies {
|
dependencies {
|
||||||
"testImplementation"(kotlin("test-junit5"))
|
"testImplementation"(kotlin("test-junit5"))?.because(b)
|
||||||
|
|
||||||
"testApi"("org.junit.jupiter:junit-jupiter-api:${Versions.junit}")
|
"testApi"("org.junit.jupiter:junit-jupiter-api:${Versions.junit}")?.because(b)
|
||||||
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:${Versions.junit}")
|
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:${Versions.junit}")?.because(b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isKotlinMpp -> {
|
isKotlinMpp -> {
|
||||||
kotlinSourceSets?.forEach { sourceSet ->
|
kotlinSourceSets?.forEach { sourceSet ->
|
||||||
if (sourceSet.name == "common") {
|
fun configureJvmTest(sourceSet: KotlinSourceSet) {
|
||||||
sourceSet.dependencies {
|
sourceSet.dependencies {
|
||||||
implementation(kotlin("test"))
|
implementation(kotlin("test-junit5"))?.because(b)
|
||||||
implementation(kotlin("test-annotations-common"))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sourceSet.dependencies {
|
|
||||||
implementation(kotlin("test-junit5"))
|
|
||||||
|
|
||||||
implementation("org.junit.jupiter:junit-jupiter-api:${Versions.junit}")
|
implementation("org.junit.jupiter:junit-jupiter-api:${Versions.junit}")?.because(b)
|
||||||
implementation("org.junit.jupiter:junit-jupiter-engine:${Versions.junit}")
|
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.junit}")?.because(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val target = kotlinTargets.orEmpty()
|
||||||
|
.find { it.name == sourceSet.name.substringBeforeLast("Main").substringBeforeLast("Test") }
|
||||||
|
|
||||||
|
when {
|
||||||
|
sourceSet.name == "commonTest" -> {
|
||||||
|
if (target?.platformType == KotlinPlatformType.jvm || target?.platformType == KotlinPlatformType.androidJvm) {
|
||||||
|
configureJvmTest(sourceSet)
|
||||||
|
} else {
|
||||||
|
sourceSet.dependencies {
|
||||||
|
implementation(kotlin("test"))?.because(b)
|
||||||
|
implementation(kotlin("test-annotations-common"))?.because(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceSet.name.contains("test", ignoreCase = true) -> {
|
||||||
|
configureJvmTest(sourceSet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ kotlin {
|
|||||||
val androidTest by getting {
|
val androidTest by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("test", Versions.kotlinCompiler))
|
implementation(kotlin("test", Versions.kotlinCompiler))
|
||||||
implementation(kotlin("test-junit", Versions.kotlinCompiler))
|
implementation(kotlin("test-junit5", Versions.kotlinCompiler))
|
||||||
implementation(kotlin("test-annotations-common"))
|
implementation(kotlin("test-annotations-common"))
|
||||||
implementation(kotlin("test-common"))
|
implementation(kotlin("test-common"))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user