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/4474/head
Konstantin 9 months ago committed by Igor Demin
parent
commit
0402c28803
  1. 14
      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

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

@ -140,12 +140,14 @@ 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 +
val depStringNotation = dep.let { "${it.group}:${it.name}:${it.version}" } getByName(commonSourceSet.apiConfigurationName).allDependencies
depStringNotation == ComposePlugin.CommonComponentsDependencies.resources }.any { dep ->
} val depStringNotation = dep.let { "${it.group}:${it.name}:${it.version}" }
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