diff --git a/libraries/stdlib/build.gradle.kts b/libraries/stdlib/build.gradle.kts index 28f8bd65b7d..8bc87739bc4 100644 --- a/libraries/stdlib/build.gradle.kts +++ b/libraries/stdlib/build.gradle.kts @@ -15,7 +15,7 @@ import plugins.publishing.* import kotlin.io.path.copyTo plugins { - id("kotlin-multiplatform") + kotlin("multiplatform") `maven-publish` signing } @@ -299,11 +299,7 @@ kotlin { } commonTest { dependencies { - // TODO: use project dependency when kotlin-test is migrated - compileOnly("org.jetbrains.kotlin:kotlin-test-common:$bootstrapKotlinVersion") - compileOnly("org.jetbrains.kotlin:kotlin-test-annotations-common:$bootstrapKotlinVersion") -// compileOnly(project(":kotlin-test:kotlin-test-common")) -// compileOnly(project(":kotlin-test:kotlin-test-annotations-common")) + api(kotlinTest()) } kotlin { srcDir("common/test") @@ -340,7 +336,7 @@ kotlin { optIn("kotlin.io.path.ExperimentalPathApi") } dependencies { - api(project(":kotlin-test:kotlin-test-junit")) + api(kotlinTest("junit")) } kotlin.srcDir("jvm/test") kotlin.srcDir("jdk7/test") @@ -349,7 +345,7 @@ kotlin { val jvmLongRunningTest by getting { dependencies { - api(project(":kotlin-test:kotlin-test-junit")) + api(kotlinTest("junit")) } kotlin.srcDir("jvm/testLongRunning") } @@ -416,9 +412,6 @@ kotlin { } } val jsTest by getting { - dependencies { - api(project(":kotlin-test:kotlin-test-js-ir")) - } kotlin.srcDir("${jsDir}/test") } @@ -493,9 +486,6 @@ kotlin { } val wasmJsTest by getting { dependsOn(wasmCommonTest) - dependencies { - api(project(":kotlin-test:kotlin-test-wasm-js")) - } kotlin { srcDir("wasm/js/test") } @@ -512,9 +502,6 @@ kotlin { } val wasmWasiTest by getting { dependsOn(wasmCommonTest) - dependencies { - api(project(":kotlin-test:kotlin-test-wasm-wasi")) - } kotlin { srcDir("wasm/wasi/test") } @@ -724,6 +711,7 @@ tasks { } val jvmLongRunningTest by registering(Test::class) { + group = "verification" val compilation = kotlin.jvm().compilations["longRunningTest"] classpath = compilation.compileDependencyFiles + compilation.runtimeDependencyFiles + compilation.output.allOutputs testClassesDirs = compilation.output.classesDirs diff --git a/libraries/stdlib/jdk7/build.gradle b/libraries/stdlib/jdk7/build.gradle index f8d9b124819..ebd9b75800b 100644 --- a/libraries/stdlib/jdk7/build.gradle +++ b/libraries/stdlib/jdk7/build.gradle @@ -26,7 +26,6 @@ sourceSets { dependencies { api project(':kotlin-stdlib') - testApi project(':kotlin-test:kotlin-test-junit') } jar { diff --git a/libraries/stdlib/jdk8/build.gradle b/libraries/stdlib/jdk8/build.gradle index 5002eb1b144..eba194c96e4 100644 --- a/libraries/stdlib/jdk8/build.gradle +++ b/libraries/stdlib/jdk8/build.gradle @@ -9,7 +9,6 @@ RepoArtifacts.javadocJar(project) dependencies { api project(':kotlin-stdlib') api project(':kotlin-stdlib-jdk7') - testApi project(':kotlin-test:kotlin-test-junit') } sourceSets { @@ -37,7 +36,7 @@ dependencies { moduleTestApi project(':kotlin-stdlib') moduleTestApi project(':kotlin-stdlib-jdk7') moduleTestCompileOnly project - moduleTestApi project(':kotlin-test:kotlin-test-junit') + moduleTestApi RepoDependencies.kotlinTest(project, "junit") moduleTestApi "org.ow2.asm:asm:9.0" } diff --git a/libraries/stdlib/samples/build.gradle b/libraries/stdlib/samples/build.gradle index d2e2db138cc..0478eadee21 100644 --- a/libraries/stdlib/samples/build.gradle +++ b/libraries/stdlib/samples/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'kotlin' dependencies { api project(':kotlin-stdlib-jdk8') - testApi project(':kotlin-test:kotlin-test-junit') + testApi RepoDependencies.kotlinTest(project, "junit") } sourceSets { diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt index 5989559ad21..d69c7b2cef4 100644 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt +++ b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt @@ -61,6 +61,37 @@ fun Project.kotlinStdlib(suffix: String? = null, classifier: String? = null): An dependencies.project(listOfNotNull(":kotlin-stdlib", suffix).joinToString("-"), classifier) } +/** + * Use this function to declare a dependency on kotlin-test project artifacts. + * + * It creates either a project dependency or a binary dependency on bootstrap artifacts when JPS build is imported. + * + * @param suffix Supported suffixes are: + * - `null` for the default project dependency, variant is resolved by attributes + * - `junit`, `junit5`, `testng` - jvm variants with annotation typealiases for different test frameworks, + * - `js` - js variant with assertions and annotations + * @param classifier Supported classifiers are: `null` for the runtime artifact, `sources` for the sources jar artifact + */ +@JvmOverloads +fun Project.kotlinTest(suffix: String? = null, classifier: String? = null): Any { + return run { + val elementsType = when (classifier) { + null -> "Runtime" + "sources" -> "Sources" + else -> error("Unsupported kotlin-test classifier: $classifier") + } + val configuration = when (suffix?.lowercase()) { + null -> classifier?.let { "jvm${elementsType}Elements" } + "junit" -> "jvmJUnit${elementsType}Elements" + "junit5" -> "jvmJUnit5${elementsType}Elements" + "testng" -> "jvmTestNG${elementsType}Elements" + "js" -> "js${elementsType}Elements" + else -> error("Unsupported kotlin-test flavor: $suffix") + } + dependencies.project(":kotlin-test", configuration) + } +} + fun Project.kotlinBuiltins(): Any = kotlinBuiltins(forJvm = false) fun Project.kotlinBuiltins(forJvm: Boolean): Any =