[Gradle] Enable Multiplatform/Android SourceSetLayout v2 by default
^KT-58281 Verification Pending
This commit is contained in:
committed by
Space Team
parent
56ba5a284d
commit
f2270ccdc7
-26
@@ -1626,32 +1626,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
// https://youtrack.jetbrains.com/issue/KT-48436
|
||||
@Test
|
||||
fun testUnusedSourceSetsReportAndroid() = with(Project("new-mpp-android", gradleVersion)) {
|
||||
setupWorkingDir()
|
||||
|
||||
val currentGradleVersion = chooseWrapperVersionOrFinishTest()
|
||||
build(
|
||||
"assembleDebug",
|
||||
// https://issuetracker.google.com/issues/152187160
|
||||
options = defaultBuildOptions().copy(
|
||||
androidGradlePluginVersion = AGPVersion.v4_2_0,
|
||||
).suppressDeprecationWarningsOn(
|
||||
"AGP uses deprecated IncrementalTaskInputs (Gradle 7.5); relies on FileTrees for ignoring empty directories when using @SkipWhenEmpty (Gradle 7.4)"
|
||||
) { options ->
|
||||
GradleVersion.version(currentGradleVersion) >= GradleVersion.version(TestVersions.Gradle.G_7_5) && options.safeAndroidGradlePluginVersion < AGPVersion.v7_3_0
|
||||
}
|
||||
) {
|
||||
assertSuccessful()
|
||||
assertNotContains(
|
||||
UnusedSourceSetsChecker.WARNING_PREFIX_ONE,
|
||||
UnusedSourceSetsChecker.WARNING_PREFIX_MANY,
|
||||
UnusedSourceSetsChecker.WARNING_INTRO
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementalCompilation() = with(Project("new-mpp-jvm-js-ic", gradleVersion)) {
|
||||
setupWorkingDir()
|
||||
|
||||
+42
-8
@@ -5,9 +5,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.android
|
||||
|
||||
import org.gradle.api.logging.configuration.WarningMode
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.UnusedSourceSetsChecker
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.AGP.AGP_70
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.AGP.AGP_71
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.Gradle.G_7_1
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.Gradle.G_7_2
|
||||
import org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask
|
||||
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
||||
import org.jetbrains.kotlin.gradle.util.testResolveAllConfigurations
|
||||
@@ -26,6 +30,8 @@ import kotlin.test.*
|
||||
|
||||
@DisplayName("kotlin-android with mpp")
|
||||
@AndroidGradlePluginTests
|
||||
@GradleTestVersions(minVersion = G_7_1)
|
||||
@AndroidTestVersions(minVersion = AGP_70)
|
||||
class KotlinAndroidMppIT : KGPBaseTest() {
|
||||
@DisplayName("KT-50736: whenEvaluated waits for AGP being applied later")
|
||||
@GradleAndroidTest
|
||||
@@ -128,6 +134,8 @@ class KotlinAndroidMppIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@AndroidTestVersions(minVersion = AGP_71)
|
||||
@GradleTestVersions(minVersion = G_7_2)
|
||||
@DisplayName("mpp source sets are registered in AGP")
|
||||
@GradleAndroidTest
|
||||
fun testAndroidMppSourceSets(
|
||||
@@ -159,13 +167,13 @@ class KotlinAndroidMppIT : KGPBaseTest() {
|
||||
assertOutputContainsOsIndependent("JNI libraries: [lib/src/main/jniLibs, lib/src/androidMain/jniLibs]")
|
||||
assertOutputContainsOsIndependent("Java-style resources: [lib/src/main/resources, lib/src/androidMain/resources]")
|
||||
|
||||
assertOutputContainsOsIndependent("Android resources: [lib/src/androidTestDebug/res, lib/src/androidAndroidTestDebug/res]")
|
||||
assertOutputContainsOsIndependent("Assets: [lib/src/androidTestDebug/assets, lib/src/androidAndroidTestDebug/assets]")
|
||||
assertOutputContainsOsIndependent("AIDL sources: [lib/src/androidTestDebug/aidl, lib/src/androidAndroidTestDebug/aidl]")
|
||||
assertOutputContainsOsIndependent("RenderScript sources: [lib/src/androidTestDebug/rs, lib/src/androidAndroidTestDebug/rs]")
|
||||
assertOutputContainsOsIndependent("JNI sources: [lib/src/androidTestDebug/jni, lib/src/androidAndroidTestDebug/jni]")
|
||||
assertOutputContainsOsIndependent("JNI libraries: [lib/src/androidTestDebug/jniLibs, lib/src/androidAndroidTestDebug/jniLibs]")
|
||||
assertOutputContainsOsIndependent("Java-style resources: [lib/src/androidTestDebug/resources, lib/src/androidAndroidTestDebug/resources]")
|
||||
assertOutputContainsOsIndependent("Android resources: [lib/src/androidTestDebug/res, lib/src/androidInstrumentedTestDebug/res]")
|
||||
assertOutputContainsOsIndependent("Assets: [lib/src/androidTestDebug/assets, lib/src/androidInstrumentedTestDebug/assets]")
|
||||
assertOutputContainsOsIndependent("AIDL sources: [lib/src/androidTestDebug/aidl, lib/src/androidInstrumentedTestDebug/aidl]")
|
||||
assertOutputContainsOsIndependent("RenderScript sources: [lib/src/androidTestDebug/rs, lib/src/androidInstrumentedTestDebug/rs]")
|
||||
assertOutputContainsOsIndependent("JNI sources: [lib/src/androidTestDebug/jni, lib/src/androidInstrumentedTestDebug/jni]")
|
||||
assertOutputContainsOsIndependent("JNI libraries: [lib/src/androidTestDebug/jniLibs, lib/src/androidInstrumentedTestDebug/jniLibs]")
|
||||
assertOutputContainsOsIndependent("Java-style resources: [lib/src/androidTestDebug/resources, lib/src/androidInstrumentedTestDebug/resources]")
|
||||
|
||||
assertOutputContainsOsIndependent("Java-style resources: [lib/betaSrc/paidBeta/resources, lib/src/androidPaidBeta/resources]")
|
||||
assertOutputContainsOsIndependent("Java-style resources: [lib/betaSrc/paidBetaDebug/resources, lib/src/androidPaidBetaDebug/resources]")
|
||||
@@ -192,6 +200,8 @@ class KotlinAndroidMppIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@AndroidTestVersions(minVersion = AGP_71)
|
||||
@GradleTestVersions(minVersion = G_7_2)
|
||||
@DisplayName("android mpp lib flavors publication can be configured")
|
||||
@GradleAndroidTest
|
||||
fun testMppAndroidLibFlavorsPublication(
|
||||
@@ -418,6 +428,7 @@ class KotlinAndroidMppIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Sources publication can be disabled")
|
||||
@GradleAndroidTest
|
||||
fun testDisableSourcesPublication(
|
||||
@@ -643,6 +654,8 @@ class KotlinAndroidMppIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@AndroidTestVersions(minVersion = AGP_71)
|
||||
@GradleTestVersions(minVersion = G_7_2)
|
||||
@DisplayName("KT-27714: custom attributes are copied to android compilation configurations")
|
||||
@GradleAndroidTest
|
||||
fun testCustomAttributesInAndroidTargets(
|
||||
@@ -987,4 +1000,25 @@ class KotlinAndroidMppIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// https://youtrack.jetbrains.com/issue/KT-48436
|
||||
@GradleAndroidTest
|
||||
fun testUnusedSourceSetsReportAndroid(
|
||||
gradleVersion: GradleVersion,
|
||||
agpVersion: String,
|
||||
jdkVersion: JdkVersions.ProvidedJdk
|
||||
) {
|
||||
project(
|
||||
"new-mpp-android", gradleVersion,
|
||||
defaultBuildOptions.copy(androidVersion = agpVersion),
|
||||
buildJdk = jdkVersion.location
|
||||
) {
|
||||
build("assembleDebug") {
|
||||
assertOutputDoesNotContain(UnusedSourceSetsChecker.WARNING_PREFIX_ONE)
|
||||
assertOutputDoesNotContain(UnusedSourceSetsChecker.WARNING_PREFIX_MANY)
|
||||
assertOutputDoesNotContain(UnusedSourceSetsChecker.WARNING_INTRO)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-9
@@ -7,7 +7,6 @@
|
||||
package org.jetbrains.kotlin.gradle.mpp
|
||||
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.logging.configuration.WarningMode
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.*
|
||||
import org.jetbrains.kotlin.gradle.embedProject
|
||||
@@ -26,13 +25,6 @@ import java.io.File
|
||||
import java.util.*
|
||||
import java.lang.Boolean as RefBoolean
|
||||
|
||||
class AndroidAndJavaConsumeMppLibBuiltByGradle69IT : AndroidAndJavaConsumeMppLibIT() {
|
||||
override val producerAgpVersion: AGPVersion = AGPVersion.v4_2_0
|
||||
override val producerGradleVersion: GradleVersionRequired = GradleVersionRequired.Exact(
|
||||
TestVersions.Gradle.G_6_9
|
||||
)
|
||||
}
|
||||
|
||||
class AndroidAndJavaConsumeMppLibBuiltByGradle7IT : AndroidAndJavaConsumeMppLibIT() {
|
||||
override val producerAgpVersion: AGPVersion = AGPVersion.v7_0_0
|
||||
override val producerGradleVersion: GradleVersionRequired = GradleVersionRequired.AtLeast(
|
||||
@@ -73,7 +65,6 @@ abstract class AndroidAndJavaConsumeMppLibIT : BaseGradleIT() {
|
||||
fun testCases(): List<Array<Any>> {
|
||||
val consumers = listOf(
|
||||
AGPVersion.v4_2_0 to GradleVersionRequired.Exact(TestVersions.Gradle.G_6_9),
|
||||
AGPVersion.v4_2_0 to GradleVersionRequired.AtLeast(TestVersions.Gradle.G_7_0),
|
||||
AGPVersion.v7_0_0 to GradleVersionRequired.AtLeast(TestVersions.Gradle.G_7_0),
|
||||
)
|
||||
val buildParams = listOf(
|
||||
|
||||
+2
@@ -317,6 +317,8 @@ class MppCompositeBuildIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTestVersions(minVersion = TestVersions.Gradle.G_7_1)
|
||||
@AndroidTestVersions(minVersion = TestVersions.AGP.AGP_70)
|
||||
@GradleAndroidTest
|
||||
fun `test - sample6-KT-56712-umbrella-composite`(
|
||||
gradleVersion: GradleVersion, agpVersion: String, jdkVersion: JdkVersions.ProvidedJdk,
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.androidSourceSetLayoutVersion=1
|
||||
+4
-1
@@ -1,2 +1,5 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.js.generate.executable.default=false
|
||||
kotlin.js.generate.executable.default=false
|
||||
|
||||
# Test is about compatibility, only version 1 was available in previous versions
|
||||
kotlin.mpp.androidSourceSetLayoutVersion=1
|
||||
+1
-1
@@ -76,7 +76,7 @@ kotlin {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
|
||||
getByName("androidAndroidTest").dependencies {
|
||||
getByName("androidInstrumentedTest").dependencies {
|
||||
implementation(kotlin("test-junit"))
|
||||
implementation("com.android.support.test:runner:1.0.2")
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@ internal val Project.kotlinAndroidSourceSetLayout: KotlinAndroidSourceSetLayout
|
||||
get() {
|
||||
return if (kotlinExtension is KotlinMultiplatformExtension) {
|
||||
when (val version = kotlinPropertiesProvider.mppAndroidSourceSetLayoutVersion) {
|
||||
null, 1 -> multiplatformAndroidSourceSetLayoutV1
|
||||
2 -> multiplatformAndroidSourceSetLayoutV2
|
||||
1 -> multiplatformAndroidSourceSetLayoutV1
|
||||
null, 2 -> multiplatformAndroidSourceSetLayoutV2
|
||||
else -> throw IllegalArgumentException(
|
||||
"Unsupported '${PropertiesProvider.PropertyNames.KOTLIN_MPP_ANDROID_SOURCE_SET_LAYOUT_VERSION}=$version' Supported versions: {1, 2}"
|
||||
)
|
||||
|
||||
+2
-2
@@ -128,8 +128,8 @@ class IdeSourceSetConstraintTest {
|
||||
val jvmMain = kotlin.sourceSets.getByName("jvmMain")
|
||||
val jvmTest = kotlin.sourceSets.getByName("jvmTest")
|
||||
val androidMain = kotlin.sourceSets.getByName("androidMain")
|
||||
val androidUnitTest = kotlin.sourceSets.getByName("androidTest")
|
||||
val androidInstrumentedTest = kotlin.sourceSets.getByName("androidAndroidTest")
|
||||
val androidUnitTest = kotlin.sourceSets.getByName("androidUnitTest")
|
||||
val androidInstrumentedTest = kotlin.sourceSets.getByName("androidInstrumentedTest")
|
||||
|
||||
project.evaluate()
|
||||
|
||||
|
||||
+12
-12
@@ -40,8 +40,8 @@ class KotlinAndroidDependsOnEdgesTest {
|
||||
val commonMain = kotlin.sourceSets.getByName("commonMain")
|
||||
val commonTest = kotlin.sourceSets.getByName("commonTest")
|
||||
val androidMain = kotlin.sourceSets.getByName("androidMain")
|
||||
val androidTest = kotlin.sourceSets.getByName("androidTest")
|
||||
val androidAndroidTest = kotlin.sourceSets.getByName("androidAndroidTest")
|
||||
val androidUnitTest = kotlin.sourceSets.getByName("androidUnitTest")
|
||||
val androidInstrumentedTest = kotlin.sourceSets.getByName("androidInstrumentedTest")
|
||||
|
||||
assertEquals(
|
||||
setOf(commonMain), androidMain.dependsOn,
|
||||
@@ -49,13 +49,13 @@ class KotlinAndroidDependsOnEdgesTest {
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
setOf(commonTest), androidTest.dependsOn,
|
||||
"Expected androidTest to dependOn commonTest"
|
||||
setOf(commonTest), androidUnitTest.dependsOn,
|
||||
"Expected androidUnitTest to dependOn commonTest"
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
setOf(commonTest), androidAndroidTest.dependsOn,
|
||||
"Expected androidAndroidTest to dependOn commonTest"
|
||||
setOf(), androidInstrumentedTest.dependsOn,
|
||||
"Expected androidInstrumentedTest to dependOn no default SourceSet"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ class KotlinAndroidDependsOnEdgesTest {
|
||||
val commonTest = kotlin.sourceSets.getByName("commonTest")
|
||||
val jvmMain = kotlin.sourceSets.getByName("jvmMain")
|
||||
val androidMain = kotlin.sourceSets.getByName("androidMain")
|
||||
val androidTest = kotlin.sourceSets.getByName("androidTest")
|
||||
val androidAndroidTest = kotlin.sourceSets.getByName("androidAndroidTest")
|
||||
val androidUnitTest = kotlin.sourceSets.getByName("androidUnitTest")
|
||||
val androidInstrumentedTest = kotlin.sourceSets.getByName("androidInstrumentedTest")
|
||||
|
||||
assertEquals(
|
||||
setOf(commonMain, jvmMain).sorted(), androidMain.dependsOn.sorted(),
|
||||
@@ -98,13 +98,13 @@ class KotlinAndroidDependsOnEdgesTest {
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
setOf(commonTest), androidTest.dependsOn,
|
||||
"Expected androidTest to only depend on commonTest"
|
||||
setOf(commonTest), androidUnitTest.dependsOn,
|
||||
"Expected androidUnitTest to only depend on commonTest"
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
setOf(commonTest), androidAndroidTest.dependsOn,
|
||||
"Expected androidAndroidTest to only depend on commonTest"
|
||||
setOf(), androidInstrumentedTest.dependsOn,
|
||||
"Expected androidInstrumentedTest to *not* depend on commonTest"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ class KotlinAndroidSourceSetLayoutExtensionTest {
|
||||
val project = buildProjectWithMPP { }
|
||||
|
||||
assertEquals(
|
||||
multiplatformAndroidSourceSetLayoutV1, project.kotlinAndroidSourceSetLayout,
|
||||
"Expected v1 being set as default"
|
||||
multiplatformAndroidSourceSetLayoutV2, project.kotlinAndroidSourceSetLayout,
|
||||
"Expected v2 being set as default"
|
||||
)
|
||||
|
||||
project.setMultiplatformAndroidSourceSetLayoutVersion(2)
|
||||
|
||||
Reference in New Issue
Block a user