From b8be217dadf5fcc04cde0a7c72cbe38b9a455167 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 7 Feb 2024 09:14:37 +0100 Subject: [PATCH] Configure explicit dependency on the copyFonts task to fix a build (#4247) --- .../resources/AndroidTargetConfiguration.kt | 5 ++++- .../test/tests/integration/ResourcesTest.kt | 2 +- .../misc/commonResources/build.gradle.kts | 14 ++++++++++++-- .../misc/commonResources/settings.gradle.kts | 2 +- .../src/androidMain/AndroidManifest.xml | 4 ++++ 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 gradle-plugins/compose/src/test/test-projects/misc/commonResources/src/androidMain/AndroidManifest.xml 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 f5e5b4f981..91c37a0390 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 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 9a6a5d3e44..73851f43ab 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 d650b32dc6..a72fb6423f 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 0a0287df97..09cf8bcfc6 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 0000000000..96aa10f056 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/src/androidMain/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + +