From c6a069e2cf810fad255d68bd64b379385d5998a2 Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Sun, 22 Sep 2024 15:17:19 +0700 Subject: [PATCH] #762 fix support of custom build configurations --- README.md | 10 +++--- .../platform/apple/SetupAppleUtils.kt | 31 +++++++------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 3480d0a8..f3d53aa0 100755 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ buildscript { } dependencies { - classpath "dev.icerock.moko:resources-generator:0.24.2" + classpath "dev.icerock.moko:resources-generator:0.24.3" } } @@ -82,10 +82,10 @@ project build.gradle apply plugin: "dev.icerock.mobile.multiplatform-resources" dependencies { - commonMainApi("dev.icerock.moko:resources:0.24.2") - commonMainApi("dev.icerock.moko:resources-compose:0.24.2") // for compose multiplatform + commonMainApi("dev.icerock.moko:resources:0.24.3") + commonMainApi("dev.icerock.moko:resources-compose:0.24.3") // for compose multiplatform - commonTestImplementation("dev.icerock.moko:resources-test:0.24.2") + commonTestImplementation("dev.icerock.moko:resources-test:0.24.3") } multiplatformResources { @@ -132,7 +132,7 @@ should [add `export` declarations](https://kotlinlang.org/docs/multiplatform-bui ``` framework { - export("dev.icerock.moko:resources:0.24.2") + export("dev.icerock.moko:resources:0.24.3") export("dev.icerock.moko:graphics:0.9.0") // toUIColor here } ``` diff --git a/resources-generator/src/main/kotlin/dev/icerock/gradle/generator/platform/apple/SetupAppleUtils.kt b/resources-generator/src/main/kotlin/dev/icerock/gradle/generator/platform/apple/SetupAppleUtils.kt index 1d1df3a5..fe3b1151 100644 --- a/resources-generator/src/main/kotlin/dev/icerock/gradle/generator/platform/apple/SetupAppleUtils.kt +++ b/resources-generator/src/main/kotlin/dev/icerock/gradle/generator/platform/apple/SetupAppleUtils.kt @@ -152,24 +152,6 @@ internal fun registerCopyFrameworkResourcesToAppTask( if (platform == null || archs == null || configuration == null) return val kotlinMultiplatformExtension = project.extensions.getByType() - val configMap: Map = (kotlinMultiplatformExtension as? ExtensionAware) - ?.extensions - ?.findByType() - ?.xcodeConfigurationToNativeBuildType - ?: emptyMap() - - val configName: String = (configMap[configuration]?.name ?: configuration).lowercase() - // Map any configuration to standard with two types: "Debug/Release" builds - val clearConfigurationName: String = when { - configName.matches(".*debug.*".toRegex()) -> "debug" - configName.matches(".*release.*".toRegex()) -> "release" - else -> throw IllegalArgumentException( - "Invalid build configuration name: $configName. Please, update your configuration." + - "Configuration name should contains Debug or Release in name" - ) - } - val requiredKonanTargets: List = - AppleSdk.defineNativeTargets(platform, archs).map { it.name } val frameworkNames: DomainObjectSet = project.objects.domainObjectSet(String::class.java) @@ -185,10 +167,21 @@ internal fun registerCopyFrameworkResourcesToAppTask( ) xcodeTask.configure { + val configMap: Map = + (kotlinMultiplatformExtension as? ExtensionAware) + ?.extensions + ?.findByType() + ?.xcodeConfigurationToNativeBuildType + ?: emptyMap() + + val configName: String = (configMap[configuration]?.name ?: configuration).lowercase() + val requiredKonanTargets: List = + AppleSdk.defineNativeTargets(platform, archs).map { it.name } + it.dependsOn( project.tasks.withType().matching { copyTask -> val isCorrectConfiguration: Boolean = - copyTask.configuration.lowercase() == clearConfigurationName + copyTask.configuration.lowercase() == configName val isCorrectFrameworkPrefix: Boolean = copyTask.frameworkPrefix == frameworkPrefix val isCorrectKonanTarget: Boolean =