Browse Source

Use "project.findProperty" instead of "providers.valueOrNull" to fix sub-module gradle properties for res class generation

pull/4203/head v1.6.0-dev1397
Konstantin Tskhovrebov 10 months ago
parent
commit
ee26bf8bee
  1. 1
      components/gradle.properties
  2. 1
      components/resources/demo/shared/gradle.properties
  3. 9
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ComposeProjectProperties.kt
  4. 2
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt

1
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

1
components/resources/demo/shared/gradle.properties

@ -0,0 +1 @@
compose.resources.always.generate.accessors=true

9
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<Boolean> =
providers.valueOrNull(CHECK_JDK_VENDOR).toBooleanProvider(true)
fun alwaysGenerateResourceAccessors(providers: ProviderFactory): Provider<Boolean> =
providers.valueOrNull(ALWAYS_GENERATE_RESOURCE_ACCESSORS).toBooleanProvider(false)
//providers.valueOrNull works only with root gradle.properties
fun alwaysGenerateResourceAccessors(project: Project): Provider<Boolean> = project.provider {
project.findProperty(ALWAYS_GENERATE_RESOURCE_ACCESSORS)?.toString().equals("true", true)
}
fun syncResources(providers: ProviderFactory): Provider<Boolean> =
providers.valueOrNull(SYNC_RESOURCES_PROPERTY).toBooleanProvider(true)

2
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<Boolean> = provider {
if (ComposeProperties.alwaysGenerateResourceAccessors(providers).get()) {
if (ComposeProperties.alwaysGenerateResourceAccessors(project).get()) {
true
} else {
configurations

Loading…
Cancel
Save