From 8f07e0efe62a9e1463ed2b912c099476393606c0 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 29 Nov 2024 17:18:13 +0100 Subject: [PATCH] fixup! Support compose resources in native macOS framework in addition to existing executable support --- .../org/jetbrains/compose/resources/IosResources.kt | 13 ++++++++----- .../compose/test/tests/integration/ResourcesTest.kt | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt index c1d6f8d35e..ccb994d4ef 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/IosResources.kt @@ -116,6 +116,7 @@ private fun Framework.getClassifier(): String { } internal fun Framework.getSyncResourcesTaskName() = "sync${getClassifier()}ComposeResourcesForIos" + private fun Framework.isCocoapodsFramework() = name.startsWith("pod") private fun Framework.getFinalResourcesDir(): Provider { @@ -125,10 +126,9 @@ private fun Framework.getFinalResourcesDir(): Provider { } else { providers.environmentVariable("BUILT_PRODUCTS_DIR") .zip( - providers.environmentVariable("CONTENTS_FOLDER_PATH") - ) { builtProductsDir, contentsFolderPath -> - val pathSuffix = if (target.isMacTarget()) "/Resources" else "" - File("$builtProductsDir/$contentsFolderPath$pathSuffix/$IOS_COMPOSE_RESOURCES_ROOT_DIR").canonicalPath + providers.environmentVariable("UNLOCALIZED_RESOURCES_FOLDER_PATH") + ) { builtProductsDir, unlocalizedResourcesFolderPath -> + File("$builtProductsDir/$unlocalizedResourcesFolderPath/$IOS_COMPOSE_RESOURCES_ROOT_DIR").canonicalPath } .flatMap { project.objects.directoryProperty().apply { set(File(it)) } @@ -142,8 +142,11 @@ private fun KotlinNativeTarget.isIosSimulatorTarget(): Boolean = private fun KotlinNativeTarget.isIosDeviceTarget(): Boolean = konanTarget === KonanTarget.IOS_ARM64 +private fun KotlinNativeTarget.isIosTarget(): Boolean = + isIosSimulatorTarget() || isIosDeviceTarget() + private fun KotlinNativeTarget.isMacTarget(): Boolean = konanTarget === KonanTarget.MACOS_X64 || konanTarget === KonanTarget.MACOS_ARM64 private fun KotlinNativeTarget.isIosOrMacTarget(): Boolean = - isIosSimulatorTarget() || isIosDeviceTarget() || isMacTarget() + isIosTarget() || isMacTarget() 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 81973d61c6..68ff7907ac 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 @@ -756,9 +756,9 @@ class ResourcesTest : GradlePluginTestBase() { check.taskSkipped(":prepareComposeResourcesTaskForMacosX64Main") check.taskSkipped(":generateResourceAccessorsForMacosX64Main") - check.taskSkipped(":syncPodComposeResourcesForMacos") + check.taskSkipped(":syncPodComposeResourcesForIos") } - gradle(":syncPodComposeResourcesForMacos").checks { + gradle(":syncPodComposeResourcesForIos").checks { check.taskNoSource(":convertXmlValueResourcesForCommonMain") check.taskSuccessful(":copyNonXmlValueResourcesForCommonMain") check.taskSuccessful(":prepareComposeResourcesTaskForCommonMain")