[MPP] Validate which configurations resolve for explicit stdlib-js dependency
^KT-60901 ^KT-61126
This commit is contained in:
committed by
Space Team
parent
78e09816e5
commit
d25d0e4f94
+5
-5
@@ -52,11 +52,11 @@ internal class NativeExternalDependenciesIT : KGPBaseTest() {
|
|||||||
0 native-external-dependencies
|
0 native-external-dependencies
|
||||||
1 io.ktor:ktor-io,io.ktor:ktor-io-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[2.3.3] #0[2.3.3]
|
1 io.ktor:ktor-io,io.ktor:ktor-io-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[2.3.3] #0[2.3.3]
|
||||||
/some/path/ktor-io.klib
|
/some/path/ktor-io.klib
|
||||||
2 org.jetbrains.kotlin:kotlin-stdlib[$KOTLIN_VERSION] #0[$KOTLIN_VERSION] #4[$KOTLIN_VERSION] #3[$KOTLIN_VERSION]
|
2 org.jetbrains.kotlin:kotlin-stdlib[$KOTLIN_VERSION] #0[$KOTLIN_VERSION] #4[1.8.20] #3[1.8.20]
|
||||||
3 org.jetbrains.kotlin:kotlin-stdlib-jdk7[$KOTLIN_VERSION] #4[$KOTLIN_VERSION]
|
3 org.jetbrains.kotlin:kotlin-stdlib-jdk7[1.8.20] #4[1.8.20]
|
||||||
/some/path/kotlin-stdlib-jdk7-$KOTLIN_VERSION.jar
|
/some/path/kotlin-stdlib-jdk7-1.8.20.jar
|
||||||
4 org.jetbrains.kotlin:kotlin-stdlib-jdk8[$KOTLIN_VERSION] #6[1.8.20]
|
4 org.jetbrains.kotlin:kotlin-stdlib-jdk8[1.8.20] #6[1.8.20]
|
||||||
/some/path/kotlin-stdlib-jdk8-$KOTLIN_VERSION.jar
|
/some/path/kotlin-stdlib-jdk8-1.8.20.jar
|
||||||
5 org.jetbrains.kotlinx:atomicfu,org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[0.21.0] #6[0.21.0] #1[0.19.0]
|
5 org.jetbrains.kotlinx:atomicfu,org.jetbrains.kotlinx:atomicfu-$DEFAULT_CURRENT_PLATFORM_TARGET_NAME_POSTFIX[0.21.0] #6[0.21.0] #1[0.19.0]
|
||||||
/some/path/atomicfu.klib
|
/some/path/atomicfu.klib
|
||||||
/some/path/atomicfu-cinterop-interop.klib
|
/some/path/atomicfu-cinterop-interop.klib
|
||||||
|
|||||||
+127
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("FunctionName")
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.dependencyResolutionTests.tcs
|
||||||
|
|
||||||
|
import org.gradle.api.artifacts.ResolveException
|
||||||
|
import org.jetbrains.kotlin.gradle.dependencyResolutionTests.mavenCentralCacheRedirector
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.resolveMetadata
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyResolution
|
||||||
|
import org.jetbrains.kotlin.gradle.util.*
|
||||||
|
import org.junit.jupiter.api.assertDoesNotThrow
|
||||||
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class StdlibJsExplicitDependencyResolutionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `project with jvm and js targets - with stdlib-js dependency in commonMain - fails to resolve jvm compile classpath`() {
|
||||||
|
checkKmpProjectResolvesAllMetadataConfigurationsAnd(
|
||||||
|
configurationsThatMustFail = listOf(
|
||||||
|
// jvm must not resolve, so that stdlib-js doesn't get onto jvm compile classpath
|
||||||
|
"jvmCompileClasspath",
|
||||||
|
) + unresolvableMetadataConfigurations,
|
||||||
|
configurationsThatMustResolve = listOf(
|
||||||
|
"jsCompileClasspath"
|
||||||
|
),
|
||||||
|
sourceSetWithStdlibJs = "commonMain"
|
||||||
|
) {
|
||||||
|
jvm()
|
||||||
|
js()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `project with jvm and js targets - with stdlib-js dependency in jsMain - resolves js and jvm compile classpaths`() {
|
||||||
|
checkKmpProjectResolvesAllMetadataConfigurationsAnd(
|
||||||
|
configurationsThatMustFail = unresolvableMetadataConfigurations,
|
||||||
|
configurationsThatMustResolve = listOf(
|
||||||
|
"jsCompileClasspath",
|
||||||
|
"jvmCompileClasspath",
|
||||||
|
),
|
||||||
|
sourceSetWithStdlibJs = "jsMain",
|
||||||
|
) {
|
||||||
|
jvm()
|
||||||
|
js()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `project js target - with stdlib-js dependency in jsMain - resolves js compile classpath`() {
|
||||||
|
checkKmpProjectResolvesAllMetadataConfigurationsAnd(
|
||||||
|
configurationsThatMustFail = unresolvableMetadataConfigurations,
|
||||||
|
configurationsThatMustResolve = listOf("jsCompileClasspath"),
|
||||||
|
sourceSetWithStdlibJs = "jsMain",
|
||||||
|
) {
|
||||||
|
js()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `project with js target - with stdlib-js dependency in commonMain - resolves js compile classpath`() {
|
||||||
|
checkKmpProjectResolvesAllMetadataConfigurationsAnd(
|
||||||
|
configurationsThatMustFail = unresolvableMetadataConfigurations,
|
||||||
|
configurationsThatMustResolve = listOf("jsCompileClasspath"),
|
||||||
|
sourceSetWithStdlibJs = "commonMain",
|
||||||
|
) {
|
||||||
|
js()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkKmpProjectResolvesAllMetadataConfigurationsAnd(
|
||||||
|
configurationsThatMustFail: List<String>,
|
||||||
|
configurationsThatMustResolve: List<String>,
|
||||||
|
sourceSetWithStdlibJs: String,
|
||||||
|
configure: KotlinMultiplatformExtension.() -> Unit,
|
||||||
|
) {
|
||||||
|
val project = buildProject {
|
||||||
|
enableDependencyVerification(false)
|
||||||
|
repositories.mavenLocal()
|
||||||
|
repositories.mavenCentralCacheRedirector()
|
||||||
|
applyMultiplatformPlugin()
|
||||||
|
kotlin {
|
||||||
|
configure()
|
||||||
|
|
||||||
|
sourceSets.getByName(sourceSetWithStdlibJs) {
|
||||||
|
it.dependencies {
|
||||||
|
this.implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
project.evaluate()
|
||||||
|
|
||||||
|
// Metadata resolution is always expected to resolve
|
||||||
|
project.multiplatformExtension.sourceSets.forEach {
|
||||||
|
assertDoesNotThrow {
|
||||||
|
it.resolveMetadata<MetadataDependencyResolution>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurationsThatMustFail.forEach {
|
||||||
|
assertThrows<ResolveException> {
|
||||||
|
project.configurations.getByName(it).resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurationsThatMustResolve.forEach {
|
||||||
|
assertDoesNotThrow {
|
||||||
|
project.configurations.getByName(it).resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See KT-61126 for the reason these configurations are unresolvable
|
||||||
|
private val unresolvableMetadataConfigurations = listOf(
|
||||||
|
"jsMainResolvableDependenciesMetadata",
|
||||||
|
"jsTestResolvableDependenciesMetadata",
|
||||||
|
"allSourceSetsCompileDependenciesMetadata",
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -66,6 +66,7 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
|
|||||||
":kotlin-stdlib-jdk8",
|
":kotlin-stdlib-jdk8",
|
||||||
":kotlin-stdlib-wasm-js",
|
":kotlin-stdlib-wasm-js",
|
||||||
":kotlin-stdlib-wasm-wasi",
|
":kotlin-stdlib-wasm-wasi",
|
||||||
|
":kotlin-dom-api-compat",
|
||||||
":examples:annotation-processor-example",
|
":examples:annotation-processor-example",
|
||||||
":kotlin-assignment-compiler-plugin.embeddable",
|
":kotlin-assignment-compiler-plugin.embeddable",
|
||||||
":kotlin-allopen-compiler-plugin.embeddable",
|
":kotlin-allopen-compiler-plugin.embeddable",
|
||||||
|
|||||||
Reference in New Issue
Block a user