Browse Source

[resources] Fix Res class generation if the library is declared as 'api' (#4406)

fixes https://github.com/JetBrains/compose-multiplatform/issues/4405
pull/4426/head
Konstantin 10 months ago committed by GitHub
parent
commit
7ce3063911
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt
  2. 8
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt
  3. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/build.gradle.kts

8
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt

@ -140,9 +140,11 @@ private fun Project.configureResourceGenerator(commonComposeResourcesDir: File,
if (ComposeProperties.alwaysGenerateResourceAccessors(project).get()) { if (ComposeProperties.alwaysGenerateResourceAccessors(project).get()) {
true true
} else { } else {
configurations configurations.run {
.getByName(commonSourceSet.implementationConfigurationName) //because the implementation configuration doesn't extend the api in the KGP ¯\_(ツ)_/¯
.allDependencies.any { dep -> getByName(commonSourceSet.implementationConfigurationName).allDependencies +
getByName(commonSourceSet.apiConfigurationName).allDependencies
}.any { dep ->
val depStringNotation = dep.let { "${it.group}:${it.name}:${it.version}" } val depStringNotation = dep.let { "${it.group}:${it.name}:${it.version}" }
depStringNotation == ComposePlugin.CommonComponentsDependencies.resources depStringNotation == ComposePlugin.CommonComponentsDependencies.resources
} }

8
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt

@ -237,8 +237,8 @@ class ResourcesTest : GradlePluginTestBase() {
modifyText("build.gradle.kts") { str -> modifyText("build.gradle.kts") { str ->
str.replace( str.replace(
"implementation(compose.components.resources)", "api(compose.components.resources)",
"//implementation(compose.components.resources)" "//api(compose.components.resources)"
) )
} }
gradle("prepareKotlinIdeaImport").checks { gradle("prepareKotlinIdeaImport").checks {
@ -253,8 +253,8 @@ class ResourcesTest : GradlePluginTestBase() {
modifyText("build.gradle.kts") { str -> modifyText("build.gradle.kts") { str ->
str.replace( str.replace(
"//implementation(compose.components.resources)", "//api(compose.components.resources)",
"implementation(compose.components.resources)" "api(compose.components.resources)"
) )
} }
gradle("prepareKotlinIdeaImport").checks { gradle("prepareKotlinIdeaImport").checks {

4
gradle-plugins/compose/src/test/test-projects/misc/commonResources/build.gradle.kts

@ -21,7 +21,9 @@ kotlin {
dependencies { dependencies {
implementation(compose.runtime) implementation(compose.runtime)
implementation(compose.material) implementation(compose.material)
implementation(compose.components.resources) //there is the api to check correctness of the api configuration
//https://github.com/JetBrains/compose-multiplatform/issues/4405
api(compose.components.resources)
} }
} }
} }

Loading…
Cancel
Save