From ee26bf8beea595dce67fbe880aa86a8363d428ae Mon Sep 17 00:00:00 2001 From: Konstantin Tskhovrebov Date: Mon, 29 Jan 2024 14:18:06 +0100 Subject: [PATCH] Use "project.findProperty" instead of "providers.valueOrNull" to fix sub-module gradle properties for res class generation --- components/gradle.properties | 1 - components/resources/demo/shared/gradle.properties | 1 + .../application/internal/ComposeProjectProperties.kt | 9 ++++++--- .../jetbrains/compose/resources/ResourcesGenerator.kt | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 components/resources/demo/shared/gradle.properties diff --git a/components/gradle.properties b/components/gradle.properties index ebcbb0d225..dabb816d49 100644 --- a/components/gradle.properties +++ b/components/gradle.properties @@ -15,7 +15,6 @@ agp.version=8.1.2 org.jetbrains.compose.experimental.jscanvas.enabled=true org.jetbrains.compose.experimental.wasm.enabled=true org.jetbrains.compose.experimental.macos.enabled=true -compose.resources.always.generate.accessors=true compose.desktop.verbose=true compose.useMavenLocal=false diff --git a/components/resources/demo/shared/gradle.properties b/components/resources/demo/shared/gradle.properties new file mode 100644 index 0000000000..d6e0f63843 --- /dev/null +++ b/components/resources/demo/shared/gradle.properties @@ -0,0 +1 @@ +compose.resources.always.generate.accessors=true \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ComposeProjectProperties.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ComposeProjectProperties.kt index 37fee60509..f9268adf0e 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ComposeProjectProperties.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ComposeProjectProperties.kt @@ -5,10 +5,11 @@ package org.jetbrains.compose.desktop.application.internal +import org.gradle.api.Project import org.gradle.api.provider.Provider import org.gradle.api.provider.ProviderFactory -import org.jetbrains.compose.internal.utils.valueOrNull import org.jetbrains.compose.internal.utils.toBooleanProvider +import org.jetbrains.compose.internal.utils.valueOrNull internal object ComposeProperties { internal const val VERBOSE = "compose.desktop.verbose" @@ -54,8 +55,10 @@ internal object ComposeProperties { fun checkJdkVendor(providers: ProviderFactory): Provider = providers.valueOrNull(CHECK_JDK_VENDOR).toBooleanProvider(true) - fun alwaysGenerateResourceAccessors(providers: ProviderFactory): Provider = - providers.valueOrNull(ALWAYS_GENERATE_RESOURCE_ACCESSORS).toBooleanProvider(false) + //providers.valueOrNull works only with root gradle.properties + fun alwaysGenerateResourceAccessors(project: Project): Provider = project.provider { + project.findProperty(ALWAYS_GENERATE_RESOURCE_ACCESSORS)?.toString().equals("true", true) + } fun syncResources(providers: ProviderFactory): Provider = providers.valueOrNull(SYNC_RESOURCES_PROPERTY).toBooleanProvider(true) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt index f516bd9d24..b84193f8d4 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt @@ -55,7 +55,7 @@ private fun Project.configureResourceGenerator(commonComposeResourcesDir: File, //lazy check a dependency on the Resources library val shouldGenerateResourceAccessors: Provider = provider { - if (ComposeProperties.alwaysGenerateResourceAccessors(providers).get()) { + if (ComposeProperties.alwaysGenerateResourceAccessors(project).get()) { true } else { configurations