Move stdlib version alignment tests into separate test suite
^KT-54703 In Progress
This commit is contained in:
committed by
Space Team
parent
ba7f5afebe
commit
5f40ba5bd9
-178
@@ -146,184 +146,6 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@AndroidGradlePluginTests
|
||||
@DisplayName("stdlib-jdk7, stdlib-jdk8 are substituted with stdlib:1.8+")
|
||||
@GradleAndroidTest
|
||||
fun testStdlibSubstitutionAndroid(
|
||||
gradleVersion: GradleVersion,
|
||||
agpVersion: String,
|
||||
jdkVersion: JdkVersions.ProvidedJdk
|
||||
) {
|
||||
project(
|
||||
"AndroidSimpleApp",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
androidVersion = agpVersion
|
||||
),
|
||||
buildJdk = jdkVersion.location,
|
||||
) {
|
||||
// Adding dependency that pulls transitively older versions
|
||||
// of stdlib-jdk8
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|dependencies {
|
||||
| implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build("checkDebugDuplicateClasses")
|
||||
}
|
||||
}
|
||||
|
||||
@AndroidGradlePluginTests
|
||||
@DisplayName("stdlib-jdk7, stdlib-jdk8 substitution with stdlib:1.8+ is possible to disable")
|
||||
@GradleAndroidTest
|
||||
fun testDisableStdlibSubstitutionAndroid(
|
||||
gradleVersion: GradleVersion,
|
||||
agpVersion: String,
|
||||
jdkVersion: JdkVersions.ProvidedJdk
|
||||
) {
|
||||
project(
|
||||
"AndroidSimpleApp",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
androidVersion = agpVersion
|
||||
),
|
||||
buildJdk = jdkVersion.location,
|
||||
) {
|
||||
// Adding dependency that pulls transitively older versions
|
||||
// of stdlib-jdk8
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|dependencies {
|
||||
| implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
gradleProperties.appendText(
|
||||
"""
|
||||
|
|
||||
|kotlin.stdlib.jdk.variants.substitution=false
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
buildAndFail("checkDebugDuplicateClasses") {
|
||||
assertOutputContains("Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("stdlib-jdk7, stdlib-jdk8 substitution with stdlib:1.8+ in Kotlin DSL")
|
||||
@GradleTest
|
||||
fun stdlibJdkVariantsSubstitutionKotlinDsl(gradleVersion: GradleVersion) {
|
||||
project("sourceSetsKotlinDsl", gradleVersion) {
|
||||
removeDependencies(buildGradleKts)
|
||||
|
||||
buildGradleKts.appendText(
|
||||
"""
|
||||
|
|
||||
|dependencies {
|
||||
| implementation(kotlin("stdlib"))
|
||||
| implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
checkTaskCompileClasspath(
|
||||
"compileKotlin",
|
||||
listOf("kotlin-stdlib"),
|
||||
checkModulesNotInClasspath = listOf("kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8"),
|
||||
isBuildGradleKts = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("KT-54653: stdlib-jdk7, jdk8 substitution should not work for unrelated configuration")
|
||||
@GradleTest
|
||||
fun stdlibJdkVariantsSubstitutionOnlyConfiguration(gradleVersion: GradleVersion) {
|
||||
project("simpleProject", gradleVersion) {
|
||||
buildGradle.modify {
|
||||
"""
|
||||
|$it
|
||||
|
|
||||
|// Stdlib-jdk8 version should be <1.8.0
|
||||
|configurations.create("specificDeps")
|
||||
|
|
||||
|dependencies {
|
||||
| specificDeps "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20"
|
||||
| implementation "org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion}"
|
||||
|}
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
build("dependencies") {
|
||||
assertOutputDoesNotContain(
|
||||
"""
|
||||
|
|
||||
|specificDeps
|
||||
|\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 -> org.jetbrains.kotlin:kotlin-stdlib:1.7.20
|
||||
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.7.20
|
||||
| \--- org.jetbrains:annotations:13.0
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("KT-54653: stdlib-jdk7, jdk8 substitution works for complex resolvable configurations hierarchy")
|
||||
@GradleTest
|
||||
fun stdlibJdkVariantSubstitutionComplexResolvableConfiguration(gradleVersion: GradleVersion) {
|
||||
project("simpleProject", gradleVersion) {
|
||||
buildGradle.modify {
|
||||
"""
|
||||
|$it
|
||||
|
|
||||
|// Stdlib-jdk8 version should be <1.8.0
|
||||
|def specificDepsConf = configurations.create("specificDeps") {
|
||||
| setCanBeResolved(true)
|
||||
|}
|
||||
|
|
||||
|configurations.create("specificDepsChild") {
|
||||
| setCanBeResolved(true)
|
||||
| extendsFrom specificDepsConf
|
||||
|}
|
||||
|
|
||||
|dependencies {
|
||||
| specificDeps "org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion}"
|
||||
| // brings transitevly older stdlib-jdk7,8 dependencies
|
||||
| specificDepsChild "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
|
||||
|}
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
build("dependencies") {
|
||||
assertOutputDoesNotContain(
|
||||
"""
|
||||
|
|
||||
|specificDepsChild
|
||||
|+--- org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion}
|
||||
|| +--- org.jetbrains.kotlin:kotlin-stdlib-common:${buildOptions.kotlinVersion}
|
||||
|| \--- org.jetbrains:annotations:13.0
|
||||
|\--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2
|
||||
| \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2
|
||||
| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30
|
||||
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> ${buildOptions.kotlinVersion} (*)
|
||||
| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30
|
||||
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> ${buildOptions.kotlinVersion} (*)
|
||||
| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.30 -> ${buildOptions.kotlinVersion}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MppGradlePluginTests
|
||||
@DisplayName("MPP: kotlin-stdlib is added by default")
|
||||
@GradleTest
|
||||
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import kotlin.io.path.appendText
|
||||
|
||||
@DisplayName("Stdlib 1.8+ version alignment")
|
||||
class StdlibAlignmentIT : KGPBaseTest() {
|
||||
|
||||
@AndroidGradlePluginTests
|
||||
@DisplayName("stdlib-jdk7, stdlib-jdk8 are substituted with stdlib:1.8+")
|
||||
@GradleAndroidTest
|
||||
fun testStdlibSubstitutionAndroid(
|
||||
gradleVersion: GradleVersion,
|
||||
agpVersion: String,
|
||||
jdkVersion: JdkVersions.ProvidedJdk
|
||||
) {
|
||||
project(
|
||||
"AndroidSimpleApp",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
androidVersion = agpVersion
|
||||
),
|
||||
buildJdk = jdkVersion.location,
|
||||
) {
|
||||
// Adding dependency that pulls transitively older versions
|
||||
// of stdlib-jdk8
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|dependencies {
|
||||
| implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build("checkDebugDuplicateClasses")
|
||||
}
|
||||
}
|
||||
|
||||
@AndroidGradlePluginTests
|
||||
@DisplayName("stdlib-jdk7, stdlib-jdk8 substitution with stdlib:1.8+ is possible to disable")
|
||||
@GradleAndroidTest
|
||||
fun testDisableStdlibSubstitutionAndroid(
|
||||
gradleVersion: GradleVersion,
|
||||
agpVersion: String,
|
||||
jdkVersion: JdkVersions.ProvidedJdk
|
||||
) {
|
||||
project(
|
||||
"AndroidSimpleApp",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
androidVersion = agpVersion
|
||||
),
|
||||
buildJdk = jdkVersion.location,
|
||||
) {
|
||||
// Adding dependency that pulls transitively older versions
|
||||
// of stdlib-jdk8
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|dependencies {
|
||||
| implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
gradleProperties.appendText(
|
||||
"""
|
||||
|
|
||||
|kotlin.stdlib.jdk.variants.substitution=false
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
buildAndFail("checkDebugDuplicateClasses") {
|
||||
assertOutputContains("Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("stdlib-jdk7, stdlib-jdk8 substitution with stdlib:1.8+ in Kotlin DSL")
|
||||
@GradleTest
|
||||
fun stdlibJdkVariantsSubstitutionKotlinDsl(gradleVersion: GradleVersion) {
|
||||
project("sourceSetsKotlinDsl", gradleVersion) {
|
||||
buildGradleKts.appendText(
|
||||
"""
|
||||
|
|
||||
|dependencies {
|
||||
| implementation(kotlin("stdlib"))
|
||||
| implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build("dependencies", "--configuration", "compileClasspath") {
|
||||
assertOutputContains(
|
||||
"""
|
||||
|\--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2
|
||||
| \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2
|
||||
| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30 -> org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion} (*)
|
||||
| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.30 -> ${buildOptions.kotlinVersion}
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("KT-54653: stdlib-jdk7, jdk8 substitution should not work for unrelated configuration")
|
||||
@GradleTest
|
||||
fun stdlibJdkVariantsSubstitutionOnlyConfiguration(gradleVersion: GradleVersion) {
|
||||
project("simpleProject", gradleVersion) {
|
||||
buildGradle.modify {
|
||||
"""
|
||||
|$it
|
||||
|
|
||||
|// Stdlib-jdk8 version should be <1.8.0
|
||||
|configurations.create("specificDeps")
|
||||
|
|
||||
|dependencies {
|
||||
| specificDeps "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20"
|
||||
| implementation "org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion}"
|
||||
|}
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
build("dependencies") {
|
||||
assertOutputDoesNotContain(
|
||||
"""
|
||||
|
|
||||
|specificDeps
|
||||
|\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 -> org.jetbrains.kotlin:kotlin-stdlib:1.7.20
|
||||
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.7.20
|
||||
| \--- org.jetbrains:annotations:13.0
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("KT-54653: stdlib-jdk7, jdk8 substitution works for complex resolvable configurations hierarchy")
|
||||
@GradleTest
|
||||
fun stdlibJdkVariantSubstitutionComplexResolvableConfiguration(gradleVersion: GradleVersion) {
|
||||
project("simpleProject", gradleVersion) {
|
||||
buildGradle.modify {
|
||||
"""
|
||||
|$it
|
||||
|
|
||||
|// Stdlib-jdk8 version should be <1.8.0
|
||||
|def specificDepsConf = configurations.create("specificDeps") {
|
||||
| setCanBeResolved(true)
|
||||
|}
|
||||
|
|
||||
|configurations.create("specificDepsChild") {
|
||||
| setCanBeResolved(true)
|
||||
| extendsFrom specificDepsConf
|
||||
|}
|
||||
|
|
||||
|dependencies {
|
||||
| specificDeps "org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion}"
|
||||
| // brings transitevly older stdlib-jdk7,8 dependencies
|
||||
| specificDepsChild "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
|
||||
|}
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
build("dependencies") {
|
||||
assertOutputDoesNotContain(
|
||||
"""
|
||||
|
|
||||
|specificDepsChild
|
||||
|+--- org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion}
|
||||
|| +--- org.jetbrains.kotlin:kotlin-stdlib-common:${buildOptions.kotlinVersion}
|
||||
|| \--- org.jetbrains:annotations:13.0
|
||||
|\--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2
|
||||
| \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2
|
||||
| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30
|
||||
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> ${buildOptions.kotlinVersion} (*)
|
||||
| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30
|
||||
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> ${buildOptions.kotlinVersion} (*)
|
||||
| \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.30 -> ${buildOptions.kotlinVersion}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user