[Gradle][KT-53342] Run functionalTests w/ AGP 7.2.1 and Java 11

This commit is contained in:
sebastian.sellmair
2022-08-01 17:31:53 +02:00
committed by Space
parent 28f293e0ce
commit f45a073dc0
12 changed files with 543 additions and 24 deletions
@@ -1,7 +1,7 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.pill.PillExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.DontIncludeResourceTransformer
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.pill.PillExtension
plugins {
id("gradle-plugin-common-configuration")
@@ -91,13 +91,13 @@ dependencies {
}
if (!kotlinBuildProperties.isInJpsBuildIdeaSync) {
"functionalTestImplementation"("com.android.tools.build:gradle:4.0.1") {
because("Functional tests are using APIs from Android. Latest Version is used to avoid NoClassDefFoundError")
}
"functionalTestImplementation"(gradleKotlinDsl())
"functionalTestImplementation"(project(":kotlin-gradle-plugin-kpm-android"))
"functionalTestImplementation"(project(":kotlin-tooling-metadata"))
"functionalTestImplementation"(testFixtures(project(":kotlin-gradle-plugin-idea")))
val functionalTestImplementation by configurations.getting
functionalTestImplementation("com.android.tools.build:gradle:7.2.1")
functionalTestImplementation("com.android.tools.build:gradle-api:7.2.1")
functionalTestImplementation(gradleKotlinDsl())
functionalTestImplementation(project(":kotlin-gradle-plugin-kpm-android"))
functionalTestImplementation(project(":kotlin-tooling-metadata"))
functionalTestImplementation(testFixtures(project(":kotlin-gradle-plugin-idea")))
}
testCompileOnly(project(":compiler"))
@@ -115,6 +115,12 @@ dependencies {
testImplementation(project(":kotlin-tooling-metadata"))
}
tasks.withType<Test>().named("functionalTest").configure {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(11))
})
}
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
configurations.commonApi.get().exclude("com.android.tools.external.com-intellij", "intellij-core")
}
@@ -162,7 +162,7 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
fun `test compilation and source set configurations don't clash`() {
val project = buildProjectWithMPP {
androidLibrary {
compileSdkVersion(30)
compileSdk = 30
}
kotlin {
@@ -36,7 +36,7 @@ class JvmAndAndroidIntermediateSourceSetTest {
/* Arbitrary minimal Android setup */
val android = project.extensions.getByName("android") as LibraryExtension
android.compileSdkVersion(30)
android.compileSdk = 31
/* Kotlin Setup */
kotlin = project.multiplatformExtension
@@ -22,7 +22,7 @@ class KT41641AbsentAndroidTarget : MultiplatformExtensionTest() {
/* Arbitrary minimal Android setup */
val android = project.extensions.getByName("android") as LibraryExtension
android.compileSdkVersion(30)
android.compileSdk = 31
kotlin.jvm()
@@ -38,7 +38,7 @@ class KT41641AbsentAndroidTarget : MultiplatformExtensionTest() {
/* Arbitrary minimal Android setup */
val android = project.extensions.getByName("android") as LibraryExtension
android.compileSdkVersion(30)
android.compileSdk = 31
kotlin.jvm()
@@ -62,7 +62,7 @@ class KT41641AbsentAndroidTarget : MultiplatformExtensionTest() {
/* Arbitrary minimal Android setup */
val android = project.extensions.getByName("android") as LibraryExtension
android.compileSdkVersion(30)
android.compileSdk = 31
kotlin.jvm()
@@ -26,7 +26,7 @@ class KotlinAndroidDependsOnEdgesTest {
/* Arbitrary minimal Android setup */
val android = project.extensions.getByName("android") as LibraryExtension
android.compileSdkVersion(30)
android.compileSdk = 31
/* Minimal MPP setup */
val kotlin = project.kotlinExtension as KotlinMultiplatformExtension
@@ -66,7 +66,7 @@ class KotlinAndroidDependsOnEdgesTest {
/* Arbitrary minimal Android setup */
val android = project.extensions.getByName("android") as LibraryExtension
android.compileSdkVersion(30)
android.compileSdk = 31
/* Custom MPP setup */
val kotlin = project.kotlinExtension as KotlinMultiplatformExtension
@@ -222,6 +222,7 @@ class KotlinMultiplatformAndroidGradlePluginCompatibilityHealthCheckTest {
/* Not yet, executed, because Android is not applied yet */
assertNoWarningMessage()
addBuildEventsListenerRegistryMock(project)
project.plugins.apply(LibraryPlugin::class.java)
assertEquals(Messages.FAILED_GETTING_ANDROID_GRADLE_PLUGIN_VERSION_STRING, assertSingleWarningMessage())
}
@@ -229,6 +230,7 @@ class KotlinMultiplatformAndroidGradlePluginCompatibilityHealthCheckTest {
@Test
fun `test - WhenAndroidIsApplied - android is applied before the health check call`() {
val project = ProjectBuilder.builder().build()
addBuildEventsListenerRegistryMock(project)
project.plugins.apply(LibraryPlugin::class.java)
project.runMultiplatformAndroidGradlePluginCompatibilityHealthCheckWhenAndroidIsApplied(
@@ -241,6 +243,7 @@ class KotlinMultiplatformAndroidGradlePluginCompatibilityHealthCheckTest {
@Test
fun `test - WhenAndroidIsApplied - called multiple times - still emits only a single message`() {
val project = ProjectBuilder.builder().build()
addBuildEventsListenerRegistryMock(project)
project.plugins.apply(LibraryPlugin::class.java)
repeat(10) {
@@ -277,6 +280,7 @@ class KotlinMultiplatformAndroidGradlePluginCompatibilityHealthCheckTest {
@Test
fun `test - is not executed when android plugin is applied - kotlin-android plugin`() {
val project = ProjectBuilder.builder().build()
addBuildEventsListenerRegistryMock(project)
project.plugins.apply("kotlin-android")
project.plugins.apply(LibraryPlugin::class.java)
@@ -66,6 +66,6 @@ class WhenEvaluatedAndroidOrderingTest {
private fun Project.applyAndroidLibraryPlugin() {
project.plugins.apply("android-library")
val android = project.extensions.getByName("android") as LibraryExtension
android.compileSdkVersion(30)
android.compileSdk = 31
}
}
@@ -18,6 +18,7 @@ import java.util.concurrent.atomic.AtomicReference
/**
* In Gradle 6.7-rc-1 BuildEventsListenerRegistry service is not created in we need it in order
* to instantiate AGP. This creates a fake one and injects it - http://b/168630734.
* https://github.com/gradle/gradle/issues/16774 (Waiting for Gradle 7.5)
*/
internal fun addBuildEventsListenerRegistryMock(project: Project) {
try {
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.gradle.kpm
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
@@ -99,10 +100,10 @@ class KotlinToolingMetadataWithModelMappingTest {
project.plugins.apply("com.android.application")
project.plugins.apply("kotlin-multiplatform")
val android = project.extensions.getByType(BaseExtension::class.java)
val android = project.extensions.getByType(ApplicationExtension::class.java)
val kotlin = multiplatformExtension
android.compileSdkVersion(28)
android.compileSdk = 31
kotlin.android()
kotlin.jvm()
kotlin.js {
@@ -10,6 +10,7 @@ package org.jetbrains.kotlin.gradle.kpm.idea
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.LibraryPlugin
import org.jetbrains.kotlin.commonizer.stdlib
import org.jetbrains.kotlin.gradle.addBuildEventsListenerRegistryMock
import org.jetbrains.kotlin.gradle.android.androidPrototype
import org.jetbrains.kotlin.gradle.assumeAndroidSdkAvailable
import org.jetbrains.kotlin.gradle.kpm.applyKpmPlugin
@@ -179,9 +180,10 @@ class MviKotlinIdeaDependencyResolutionTest : AbstractLightweightIdeaDependencyR
val project = buildProject()
/* Setup Android */
addBuildEventsListenerRegistryMock(project)
project.plugins.apply(LibraryPlugin::class.java)
val android = project.extensions.getByType(LibraryExtension::class.java)
android.compileSdkVersion(30)
android.compileSdk = 31
val kotlin = project.applyKpmPlugin {
@@ -99,10 +99,10 @@ class MultiplatformAndroidSourceSetLayoutV1Test {
fun `two product flavor dimensions`() {
android.flavorDimensions("pricing", "releaseType")
android.productFlavors {
it.create("beta").dimension = "releaseType"
it.create("production").dimension = "releaseType"
it.create("free").dimension = "pricing"
it.create("paid").dimension = "pricing"
create("beta").dimension = "releaseType"
create("production").dimension = "releaseType"
create("free").dimension = "pricing"
create("paid").dimension = "pricing"
}
kotlin.android()
project.evaluate()