Skip to content

Commit

Permalink
[resources] Fix Res class generation if the library is declared as 'a…
Browse files Browse the repository at this point in the history
…pi' (#4406)

fixes #4405
  • Loading branch information
terrakok authored Mar 4, 2024
1 parent ca3ae45 commit 7ce3063
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ private fun Project.configureResourceGenerator(commonComposeResourcesDir: File,
if (ComposeProperties.alwaysGenerateResourceAccessors(project).get()) {
true
} else {
configurations
.getByName(commonSourceSet.implementationConfigurationName)
.allDependencies.any { dep ->
val depStringNotation = dep.let { "${it.group}:${it.name}:${it.version}" }
depStringNotation == ComposePlugin.CommonComponentsDependencies.resources
}
configurations.run {
//because the implementation configuration doesn't extend the api in the KGP ¯\_(ツ)_/¯
getByName(commonSourceSet.implementationConfigurationName).allDependencies +
getByName(commonSourceSet.apiConfigurationName).allDependencies
}.any { dep ->
val depStringNotation = dep.let { "${it.group}:${it.name}:${it.version}" }
depStringNotation == ComposePlugin.CommonComponentsDependencies.resources
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class ResourcesTest : GradlePluginTestBase() {

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

modifyText("build.gradle.kts") { str ->
str.replace(
"//implementation(compose.components.resources)",
"implementation(compose.components.resources)"
"//api(compose.components.resources)",
"api(compose.components.resources)"
)
}
gradle("prepareKotlinIdeaImport").checks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ kotlin {
dependencies {
implementation(compose.runtime)
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)
}
}
}
Expand Down

0 comments on commit 7ce3063

Please sign in to comment.