Fix MPP source set dependencies missing in Android tests (KT-29343)
Add Kotlin source set dependencies to the Android source sets, and also add aggregated Kotlin compilation dependencies to the dedicated Android source sets of the Android variants. Issue #KT-29343 Fixed
This commit is contained in:
+55
-4
@@ -1,10 +1,7 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.getFilesByNames
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
@@ -211,6 +208,60 @@ open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAndroidMppProductionDependenciesInTests() = with(Project("new-mpp-android", GradleVersionRequired.AtLeast("4.7"))) {
|
||||
// Test the fix for KT-29343
|
||||
setupWorkingDir()
|
||||
|
||||
gradleBuildScript("lib").appendText(
|
||||
"\n" + """
|
||||
kotlin.sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin("stdlib-common")
|
||||
}
|
||||
}
|
||||
androidLibDebug {
|
||||
dependencies {
|
||||
implementation kotlin("reflect")
|
||||
}
|
||||
}
|
||||
androidLibRelease {
|
||||
dependencies {
|
||||
implementation kotlin("test-junit")
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val kotlinVersion = defaultBuildOptions().kotlinVersion
|
||||
testResolveAllConfigurations("lib") {
|
||||
assertSuccessful()
|
||||
|
||||
// commonMain:
|
||||
assertContains(">> :lib:debugCompileClasspath --> kotlin-stdlib-common-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:releaseCompileClasspath --> kotlin-stdlib-common-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:debugAndroidTestCompileClasspath --> kotlin-stdlib-common-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:debugUnitTestCompileClasspath --> kotlin-stdlib-common-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:releaseUnitTestCompileClasspath --> kotlin-stdlib-common-$kotlinVersion.jar")
|
||||
|
||||
// androidLibDebug:
|
||||
assertContains(">> :lib:debugCompileClasspath --> kotlin-reflect-$kotlinVersion.jar")
|
||||
assertNotContains(">> :lib:releaseCompileClasspath --> kotlin-reflect-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:debugAndroidTestCompileClasspath --> kotlin-reflect-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:debugUnitTestCompileClasspath --> kotlin-reflect-$kotlinVersion.jar")
|
||||
assertNotContains(">> :lib:releaseUnitTestCompileClasspath --> kotlin-reflect-$kotlinVersion.jar")
|
||||
|
||||
// androidLibRelease:
|
||||
assertNotContains(">> :lib:debugCompileClasspath --> kotlin-test-junit-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:releaseCompileClasspath --> kotlin-test-junit-$kotlinVersion.jar")
|
||||
assertNotContains(">> :lib:debugAndroidTestCompileClasspath --> kotlin-test-junit-$kotlinVersion.jar")
|
||||
assertNotContains(">> :lib:debugUnitTestCompileClasspath --> kotlin-test-junit-$kotlinVersion.jar")
|
||||
assertContains(">> :lib:releaseUnitTestCompileClasspath --> kotlin-test-junit-$kotlinVersion.jar")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCustomAttributesInAndroidTargets() = with(Project("new-mpp-android", GradleVersionRequired.AtLeast("5.0"))) {
|
||||
// Test the fix for KT-27714
|
||||
|
||||
Reference in New Issue
Block a user