Draft: change stdlib autoconfiguration and import expectations for mpp stdlib
#KT-59000
This commit is contained in:
committed by
Space Team
parent
d5fd6937ce
commit
09bb0b5566
+6
-2
@@ -240,7 +240,10 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
).run {
|
).run {
|
||||||
build("publish") {
|
build("publish") {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
setOf("third-party-lib-metadata-1.0.jar"),
|
setOf(
|
||||||
|
"third-party-lib-metadata-1.0.jar",
|
||||||
|
"kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar",
|
||||||
|
),
|
||||||
transformedArtifacts()
|
transformedArtifacts()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -256,7 +259,8 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
assertEquals(
|
assertEquals(
|
||||||
setOf(
|
setOf(
|
||||||
"my-lib-foo-metadata-1.0-all.jar",
|
"my-lib-foo-metadata-1.0-all.jar",
|
||||||
"third-party-lib-metadata-1.0.jar"
|
"third-party-lib-metadata-1.0.jar",
|
||||||
|
"kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar",
|
||||||
),
|
),
|
||||||
transformedArtifacts()
|
transformedArtifacts()
|
||||||
)
|
)
|
||||||
|
|||||||
+8
-8
@@ -35,7 +35,7 @@ internal const val KOTLIN_STDLIB_JDK7_MODULE_NAME = "kotlin-stdlib-jdk7"
|
|||||||
internal const val KOTLIN_STDLIB_JDK8_MODULE_NAME = "kotlin-stdlib-jdk8"
|
internal const val KOTLIN_STDLIB_JDK8_MODULE_NAME = "kotlin-stdlib-jdk8"
|
||||||
internal const val KOTLIN_STDLIB_JS_MODULE_NAME = "kotlin-stdlib-js"
|
internal const val KOTLIN_STDLIB_JS_MODULE_NAME = "kotlin-stdlib-js"
|
||||||
internal const val KOTLIN_STDLIB_WASM_MODULE_NAME = "kotlin-stdlib-wasm"
|
internal const val KOTLIN_STDLIB_WASM_MODULE_NAME = "kotlin-stdlib-wasm"
|
||||||
internal const val KOTLIN_ANDROID_JVM_STDLIB_MODULE_NAME = KOTLIN_STDLIB_JDK8_MODULE_NAME
|
internal const val KOTLIN_ANDROID_JVM_STDLIB_MODULE_NAME = KOTLIN_STDLIB_MODULE_NAME
|
||||||
|
|
||||||
internal fun Project.configureStdlibDefaultDependency(
|
internal fun Project.configureStdlibDefaultDependency(
|
||||||
topLevelExtension: KotlinTopLevelExtension,
|
topLevelExtension: KotlinTopLevelExtension,
|
||||||
@@ -111,18 +111,18 @@ private fun addStdlibToKpmProject(
|
|||||||
project.pm20Extension.modules.named(GradleKpmModule.MAIN_MODULE_NAME) { main ->
|
project.pm20Extension.modules.named(GradleKpmModule.MAIN_MODULE_NAME) { main ->
|
||||||
main.fragments.named(GradleKpmFragment.COMMON_FRAGMENT_NAME) { common ->
|
main.fragments.named(GradleKpmFragment.COMMON_FRAGMENT_NAME) { common ->
|
||||||
common.dependencies {
|
common.dependencies {
|
||||||
api(project.dependencies.kotlinDependency(KOTLIN_STDLIB_COMMON_MODULE_NAME, coreLibrariesVersion.get()))
|
api(project.dependencies.kotlinDependency(KOTLIN_STDLIB_MODULE_NAME, coreLibrariesVersion.get()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
main.variants.configureEach { variant ->
|
main.variants.configureEach { variant ->
|
||||||
val dependencyHandler = project.dependencies
|
val dependencyHandler = project.dependencies
|
||||||
val stdlibModule = when (variant.platformType) {
|
val stdlibModule = when (variant.platformType) {
|
||||||
KotlinPlatformType.common -> error("variants are not expected to be common")
|
KotlinPlatformType.common -> error("variants are not expected to be common")
|
||||||
KotlinPlatformType.jvm -> KOTLIN_STDLIB_JDK8_MODULE_NAME
|
KotlinPlatformType.jvm -> KOTLIN_STDLIB_MODULE_NAME
|
||||||
KotlinPlatformType.js -> KOTLIN_STDLIB_JS_MODULE_NAME
|
KotlinPlatformType.js -> KOTLIN_STDLIB_MODULE_NAME
|
||||||
KotlinPlatformType.wasm -> KOTLIN_STDLIB_WASM_MODULE_NAME
|
KotlinPlatformType.wasm -> KOTLIN_STDLIB_WASM_MODULE_NAME
|
||||||
KotlinPlatformType.androidJvm -> null // TODO: expect support on the AGP side?
|
KotlinPlatformType.androidJvm -> null // TODO: expect support on the AGP side?
|
||||||
KotlinPlatformType.native -> null
|
KotlinPlatformType.native -> KOTLIN_STDLIB_MODULE_NAME
|
||||||
}
|
}
|
||||||
if (stdlibModule != null) {
|
if (stdlibModule != null) {
|
||||||
variant.dependencies {
|
variant.dependencies {
|
||||||
@@ -203,7 +203,7 @@ internal fun KotlinPlatformType.stdlibPlatformType(
|
|||||||
kotlinTarget: KotlinTarget,
|
kotlinTarget: KotlinTarget,
|
||||||
kotlinSourceSet: KotlinSourceSet
|
kotlinSourceSet: KotlinSourceSet
|
||||||
): String? = when (this) {
|
): String? = when (this) {
|
||||||
KotlinPlatformType.jvm -> KOTLIN_STDLIB_JDK8_MODULE_NAME
|
KotlinPlatformType.jvm -> KOTLIN_STDLIB_MODULE_NAME
|
||||||
KotlinPlatformType.androidJvm -> {
|
KotlinPlatformType.androidJvm -> {
|
||||||
if (kotlinTarget is KotlinAndroidTarget &&
|
if (kotlinTarget is KotlinAndroidTarget &&
|
||||||
kotlinSourceSet.androidSourceSetInfoOrNull?.androidSourceSetName == AndroidBaseSourceSetName.Main.name
|
kotlinSourceSet.androidSourceSetInfoOrNull?.androidSourceSetName == AndroidBaseSourceSetName.Main.name
|
||||||
@@ -214,11 +214,11 @@ internal fun KotlinPlatformType.stdlibPlatformType(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KotlinPlatformType.js -> KOTLIN_STDLIB_JS_MODULE_NAME
|
KotlinPlatformType.js -> KOTLIN_STDLIB_MODULE_NAME
|
||||||
KotlinPlatformType.wasm -> KOTLIN_STDLIB_WASM_MODULE_NAME
|
KotlinPlatformType.wasm -> KOTLIN_STDLIB_WASM_MODULE_NAME
|
||||||
KotlinPlatformType.native -> null
|
KotlinPlatformType.native -> null
|
||||||
KotlinPlatformType.common -> // there's no platform compilation that the source set is default for
|
KotlinPlatformType.common -> // there's no platform compilation that the source set is default for
|
||||||
KOTLIN_STDLIB_COMMON_MODULE_NAME
|
KOTLIN_STDLIB_MODULE_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
private val androidTestVariants = setOf(AndroidVariantType.UnitTest, AndroidVariantType.InstrumentedTest)
|
private val androidTestVariants = setOf(AndroidVariantType.UnitTest, AndroidVariantType.InstrumentedTest)
|
||||||
|
|||||||
+9
-9
@@ -36,8 +36,8 @@ class IdeStdlibResolutionTest {
|
|||||||
|
|
||||||
project.evaluate()
|
project.evaluate()
|
||||||
|
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonMain"), jvmStdlibDependencies(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonMain"), jvmStdlibDependencies(kotlin) + commonStdlibDependency(kotlin))
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonTest"), jvmStdlibDependencies(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonTest"), jvmStdlibDependencies(kotlin) + commonStdlibDependency(kotlin))
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jvmMain"), jvmStdlibDependencies(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jvmMain"), jvmStdlibDependencies(kotlin))
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jvmTest"), jvmStdlibDependencies(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jvmTest"), jvmStdlibDependencies(kotlin))
|
||||||
}
|
}
|
||||||
@@ -66,8 +66,8 @@ class IdeStdlibResolutionTest {
|
|||||||
|
|
||||||
project.evaluate()
|
project.evaluate()
|
||||||
|
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonMain"), jsStdlibDependency(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonMain"), listOf(commonStdlibDependency(kotlin), jsStdlibDependency(kotlin)))
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonTest"), jsStdlibDependency(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("commonTest"), listOf(commonStdlibDependency(kotlin), jsStdlibDependency(kotlin)))
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jsMain"), jsStdlibDependency(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jsMain"), jsStdlibDependency(kotlin))
|
||||||
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jsTest"), jsStdlibDependency(kotlin))
|
project.assertStdlibDependencies(kotlin.sourceSets.getByName("jsTest"), jsStdlibDependency(kotlin))
|
||||||
}
|
}
|
||||||
@@ -116,8 +116,8 @@ class IdeStdlibResolutionTest {
|
|||||||
|
|
||||||
project.assertStdlibDependencies(commonMain, commonStdlibDependency(kotlin))
|
project.assertStdlibDependencies(commonMain, commonStdlibDependency(kotlin))
|
||||||
project.assertStdlibDependencies(commonTest, commonStdlibDependency(kotlin))
|
project.assertStdlibDependencies(commonTest, commonStdlibDependency(kotlin))
|
||||||
project.assertStdlibDependencies(jvmIntermediateMain, jvmStdlibDependencies(kotlin))
|
project.assertStdlibDependencies(jvmIntermediateMain, jvmStdlibDependencies(kotlin) + commonStdlibDependency(kotlin))
|
||||||
project.assertStdlibDependencies(jvmIntermediateTest, jvmStdlibDependencies(kotlin))
|
project.assertStdlibDependencies(jvmIntermediateTest, jvmStdlibDependencies(kotlin) + commonStdlibDependency(kotlin))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -235,11 +235,11 @@ class IdeStdlibResolutionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun commonStdlibDependency(kotlin: KotlinMultiplatformExtension) =
|
private fun commonStdlibDependency(kotlin: KotlinMultiplatformExtension) =
|
||||||
binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin.coreLibrariesVersion}")
|
binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib:${kotlin.coreLibrariesVersion}:commonMain")
|
||||||
|
|
||||||
private fun jvmStdlibDependencies(kotlin: KotlinMultiplatformExtension) = listOf(
|
private fun jvmStdlibDependencies(kotlin: KotlinMultiplatformExtension) = listOf(
|
||||||
binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin.coreLibrariesVersion}"),
|
// binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin.coreLibrariesVersion}"),
|
||||||
binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin.coreLibrariesVersion}"),
|
// binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin.coreLibrariesVersion}"),
|
||||||
binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib:${kotlin.coreLibrariesVersion}"),
|
binaryCoordinates("org.jetbrains.kotlin:kotlin-stdlib:${kotlin.coreLibrariesVersion}"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user