[Gradle, MPP] Slightly rework testAndroidMultiplatformPublicationAGPCompatibility
Each AGP version has its own compatible Gradle versions range. This commit adds additional version requirements for tests to respect AGP limitations #KT-52998 In Progress
This commit is contained in:
committed by
Space Team
parent
16bf37b3f5
commit
25fb641da7
+33
-16
@@ -12,8 +12,10 @@ import org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask
|
|||||||
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
||||||
import org.jetbrains.kotlin.gradle.util.testResolveAllConfigurations
|
import org.jetbrains.kotlin.gradle.util.testResolveAllConfigurations
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
import org.junit.jupiter.api.io.TempDir
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Path
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
import kotlin.io.path.appendText
|
import kotlin.io.path.appendText
|
||||||
import kotlin.io.path.extension
|
import kotlin.io.path.extension
|
||||||
@@ -817,48 +819,63 @@ class KotlinAndroidMppIT : KGPBaseTest() {
|
|||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
agpVersion: String,
|
agpVersion: String,
|
||||||
jdkVersion: JdkVersions.ProvidedJdk,
|
jdkVersion: JdkVersions.ProvidedJdk,
|
||||||
|
@TempDir tempDir: Path
|
||||||
) {
|
) {
|
||||||
project(
|
project(
|
||||||
"new-mpp-android-agp-compatibility",
|
"new-mpp-android-agp-compatibility",
|
||||||
gradleVersion,
|
gradleVersion,
|
||||||
buildOptions = defaultBuildOptions.copy(androidVersion = agpVersion),
|
buildOptions = defaultBuildOptions.copy(androidVersion = agpVersion),
|
||||||
buildJdk = jdkVersion.location
|
buildJdk = jdkVersion.location,
|
||||||
|
localRepoDir = tempDir
|
||||||
) {
|
) {
|
||||||
/* Publish a producer library with the current version of AGP */
|
/* Publish a producer library with the current version of AGP */
|
||||||
build(":producer:publishAllPublicationsToBuildDirRepository") {
|
build(":producer:publishAllPublicationsToBuildDirRepository") {
|
||||||
/* Check expected publication layout */
|
/* Check expected publication layout */
|
||||||
assertDirectoryInProjectExists("build/repo/com/example/producer-android")
|
assertDirectoryExists(tempDir.resolve("com/example/producer-android"))
|
||||||
assertDirectoryInProjectExists("build/repo/com/example/producer-android-debug")
|
assertDirectoryExists(tempDir.resolve("com/example/producer-android-debug"))
|
||||||
assertDirectoryInProjectExists("build/repo/com/example/producer-jvm")
|
assertDirectoryExists(tempDir.resolve("com/example/producer-jvm"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val checkedConsumerAGPVersions = AGPVersion.testedVersions
|
val checkedConsumerAGPVersions = AGPVersion.testedVersions
|
||||||
.filter { version -> version >= AGPVersion.fromString(TestVersions.AGP.AGP_42) }
|
.filter { version -> version >= AGPVersion.fromString(TestVersions.AGP.AGP_42) }
|
||||||
.filter { version -> version < AGPVersion.fromString(TestVersions.AGP.MAX_SUPPORTED) }
|
.filter { version -> version < AGPVersion.fromString(TestVersions.AGP.MAX_SUPPORTED) }
|
||||||
.map { it.toString() }
|
.map { it.toString() }
|
||||||
|
|
||||||
checkedConsumerAGPVersions.forEach { consumerAgpVersion ->
|
checkedConsumerAGPVersions.forEach { consumerAgpVersion ->
|
||||||
println("Testing compatibility for AGP consumer version $consumerAgpVersion (Producer: $agpVersion)")
|
val agpTestVersion = TestVersions.AgpCompatibilityMatrix.values().find { it.version == consumerAgpVersion }
|
||||||
val buildOptions = buildOptions.copy(
|
?: fail("AGP version $consumerAgpVersion is not defined in TestVersions.AGP!")
|
||||||
|
val consumerGradleVersion = when {
|
||||||
|
gradleVersion < agpTestVersion.minSupportedGradleVersion -> agpTestVersion.minSupportedGradleVersion
|
||||||
|
gradleVersion > agpTestVersion.maxSupportedGradleVersion -> agpTestVersion.maxSupportedGradleVersion
|
||||||
|
else -> gradleVersion
|
||||||
|
}
|
||||||
|
println("Testing compatibility for AGP consumer version $consumerAgpVersion on Gradle ${consumerGradleVersion.version} (Producer: $agpVersion)")
|
||||||
|
project(
|
||||||
|
"new-mpp-android-agp-compatibility",
|
||||||
|
consumerGradleVersion,
|
||||||
|
buildOptions = defaultBuildOptions.copy(
|
||||||
androidVersion = consumerAgpVersion,
|
androidVersion = consumerAgpVersion,
|
||||||
// Workaround for a deprecation warning from AGP
|
// Workaround for a deprecation warning from AGP
|
||||||
// Relying on FileTrees for ignoring empty directories when using @SkipWhenEmpty has been deprecated.
|
// Relying on FileTrees for ignoring empty directories when using @SkipWhenEmpty has been deprecated.
|
||||||
warningMode = if (AGPVersion.fromString(consumerAgpVersion) <= AGPVersion.v7_1_0) WarningMode.None else WarningMode.Fail,
|
warningMode = if (AGPVersion.fromString(consumerAgpVersion) <= AGPVersion.v7_1_0) WarningMode.None else WarningMode.Fail,
|
||||||
)
|
),
|
||||||
|
buildJdk = jdkVersion.location,
|
||||||
|
localRepoDir = tempDir
|
||||||
|
) {
|
||||||
/*
|
/*
|
||||||
Project: multiplatformAndroidConsumer is a mpp project with jvm and android targets.
|
Project: multiplatformAndroidConsumer is a mpp project with jvm and android targets.
|
||||||
This project depends on the previous publication as 'commonMainImplementation' dependency
|
This project depends on the previous publication as 'commonMainImplementation' dependency
|
||||||
*/
|
*/
|
||||||
build(":multiplatformAndroidConsumer:assemble", buildOptions = buildOptions)
|
build(":multiplatformAndroidConsumer:assemble")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Project: plainAndroidConsumer only uses the 'kotlin("android")' plugin
|
Project: plainAndroidConsumer only uses the 'kotlin("android")' plugin
|
||||||
This project depends on the previous publication as 'implementation' dependency
|
This project depends on the previous publication as 'implementation' dependency
|
||||||
*/
|
*/
|
||||||
build(":plainAndroidConsumer:assemble", buildOptions = buildOptions)
|
build(":plainAndroidConsumer:assemble")
|
||||||
println("Successfully tested compatibility for AGP consumer version $consumerAgpVersion (Producer: $agpVersion)")
|
|
||||||
}
|
}
|
||||||
|
println("Successfully tested compatibility for AGP consumer version $consumerAgpVersion on Gradle ${consumerGradleVersion.version} (Producer: $agpVersion)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ interface TestVersions {
|
|||||||
const val AGP_42 = "4.2.2"
|
const val AGP_42 = "4.2.2"
|
||||||
const val AGP_70 = "7.0.4"
|
const val AGP_70 = "7.0.4"
|
||||||
const val AGP_71 = "7.1.3"
|
const val AGP_71 = "7.1.3"
|
||||||
const val AGP_72 = "7.2.1"
|
const val AGP_72 = "7.2.2"
|
||||||
const val AGP_73 = "7.3.0"
|
const val AGP_73 = "7.3.0"
|
||||||
const val AGP_74 = "7.4.0-rc03"
|
const val AGP_74 = "7.4.0-rc03"
|
||||||
const val AGP_80 = "8.0.0-alpha11"
|
const val AGP_80 = "8.0.0-alpha11"
|
||||||
|
|||||||
+2
-2
@@ -21,10 +21,10 @@ class AGPVersion private constructor(private val versionNumber: VersionNumber) {
|
|||||||
val v4_1_0 = fromString("4.1.3")
|
val v4_1_0 = fromString("4.1.3")
|
||||||
val v4_2_0 = fromString("4.2.2")
|
val v4_2_0 = fromString("4.2.2")
|
||||||
val v7_0_0 = fromString("7.0.4")
|
val v7_0_0 = fromString("7.0.4")
|
||||||
val v7_1_0 = fromString("7.1.2")
|
val v7_1_0 = fromString("7.1.3")
|
||||||
val v7_2_2 = fromString("7.2.2")
|
val v7_2_2 = fromString("7.2.2")
|
||||||
val v7_3_0 = fromString("7.3.0")
|
val v7_3_0 = fromString("7.3.0")
|
||||||
val v7_4_0 = fromString("7.4.0-beta05")
|
val v7_4_0 = fromString("7.4.0-rc03")
|
||||||
|
|
||||||
val testedVersions = listOf(v4_1_0, v4_2_0, v7_0_0, v7_1_0, v7_2_2, v7_3_0, v7_4_0)
|
val testedVersions = listOf(v4_1_0, v4_2_0, v7_0_0, v7_1_0, v7_2_2, v7_3_0, v7_4_0)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven(rootProject.buildDir.resolve("repo"))
|
maven("<localRepo>")
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven(rootProject.buildDir.resolve("repo"))
|
maven("<localRepo>")
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ version = "1.0.0-SNAPSHOT"
|
|||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
maven(rootProject.buildDir.resolve("repo")) {
|
maven("<localRepo>") {
|
||||||
name = "buildDir"
|
name = "buildDir"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user