From 8f42d8d608242712923fb75b123294e775eb2bf5 Mon Sep 17 00:00:00 2001 From: Konstantin Tskhovrebov Date: Tue, 6 Feb 2024 18:12:18 +0100 Subject: [PATCH 1/2] Add a failed test for https://github.com/JetBrains/compose-multiplatform/issues/4085 --- .../test/tests/integration/ResourcesTest.kt | 2 +- .../misc/commonResources/build.gradle.kts | 14 ++++++++++++-- .../misc/commonResources/settings.gradle.kts | 2 +- .../src/androidMain/AndroidManifest.xml | 4 ++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 gradle-plugins/compose/src/test/test-projects/misc/commonResources/src/androidMain/AndroidManifest.xml diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt index 9a6a5d3e44f..73851f43aba 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt @@ -112,7 +112,7 @@ class ResourcesTest : GradlePluginTestBase() { @Test fun testCopyFontsInAndroidApp(): Unit = with(testProject("misc/commonResources")) { - gradle("assembleDebug").checks { + gradle("build").checks { check.taskSuccessful(":copyFontsToAndroidAssets") } } diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/build.gradle.kts b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/build.gradle.kts index d650b32dc60..a72fb6423fb 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/build.gradle.kts +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("multiplatform") - id("com.android.library") + id("com.android.application") id("org.jetbrains.compose") } @@ -29,10 +29,20 @@ kotlin { } android { - compileSdk = 31 + compileSdk = 34 namespace = "org.jetbrains.compose.resources.test" + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { + applicationId = "org.example.project" minSdk = 21 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + } } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/settings.gradle.kts b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/settings.gradle.kts index 0a0287df974..09cf8bcfc66 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/settings.gradle.kts +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/settings.gradle.kts @@ -7,7 +7,7 @@ pluginManagement { maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } plugins { - id("com.android.library").version("AGP_VERSION_PLACEHOLDER") + id("com.android.application").version("AGP_VERSION_PLACEHOLDER") id("org.jetbrains.kotlin.multiplatform").version("KOTLIN_VERSION_PLACEHOLDER") id("org.jetbrains.compose").version("COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER") } diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/src/androidMain/AndroidManifest.xml b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/src/androidMain/AndroidManifest.xml new file mode 100644 index 00000000000..96aa10f056b --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/src/androidMain/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + From 61c7f5c983c927727596d6f6909f71d24da327ac Mon Sep 17 00:00:00 2001 From: Konstantin Tskhovrebov Date: Tue, 6 Feb 2024 18:14:19 +0100 Subject: [PATCH 2/2] Configure explicit dependency on the copyFonts task to fix a build --- .../compose/resources/AndroidTargetConfiguration.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/AndroidTargetConfiguration.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/AndroidTargetConfiguration.kt index f5e5b4f981f..91c37a03909 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/AndroidTargetConfiguration.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/AndroidTargetConfiguration.kt @@ -2,7 +2,7 @@ package org.jetbrains.compose.resources import com.android.build.api.variant.AndroidComponentsExtension import com.android.build.gradle.BaseExtension -import com.android.build.gradle.tasks.MergeSourceSetFolders +import com.android.build.gradle.internal.tasks.AndroidVariantTask import org.gradle.api.Project import org.gradle.api.provider.Provider import org.gradle.api.tasks.Copy @@ -39,4 +39,7 @@ internal fun Project.configureAndroidResources( } ) } + //fixme: it seems like a problem in AGP, so dirty hack now + //https://github.com/JetBrains/compose-multiplatform/issues/4085 + tasks.matching { it is AndroidVariantTask }.configureEach { it.dependsOn(copyFonts) } } \ No newline at end of file