You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The object variant above is gotten according to gradle command been runned.
Problem
All the rouserces added in src/commonFlavor1/composeResources/drawable are not being processed and added to Res.drawable.
Workarrouund
As a way to "solve" this I've create a task to copy the necessary resources to build/generated/compose/resourceGenerator/preparedResources/commonMain/composeResources/.
Unfortunatelly It doesn't work right after a ./gradlew clean I don't know why
funrecursiveCopy(from:File, to:File) {
if (!from.exists()) return
from.listFiles()?.forEach { file ->if (file.name !=".DS_Store") {
if (file.isDirectory) {
val newDir =File(to, file.name)
newDir.mkdir()
recursiveCopy(file, newDir)
} else {
val destinationFile =File(to, file.name)
if (destinationFile.exists()) {
println("Overwriting $destinationFile")
destinationFile.delete()
}
if (!destinationFile.parentFile.exists()) {
destinationFile.parentFile.mkdirs()
}
println("Copying $file to $to")
file.copyTo(destinationFile)
}
}
}
}
tasks.register("copyKmpResources") {
doLast {
println("\n\n--> Copying Flavored KMP Resources")
val variant =BuildSrcConfig.Variant.getVariant(project = project, gradle = gradle)
val projectDir = project.projectDir.absolutePath
val fromFlavor =File(
projectDir,
"src/common${variant.flavor.flavorName.capitalized()}/composeResources/"
)
val fromVariant =File(
projectDir,
"src/common${variant.flavor.flavorName.capitalized()}/composeResources/"
)
val destination ="build/generated/compose/resourceGenerator/preparedResources/commonMain/composeResources/"println("destination:\n$destination")
val destinationFile =File(projectDir, destination)
println(" - copying \"$fromFlavor\" to \"$destinationFile\"")
recursiveCopy(fromFlavor, destinationFile)
println(" - copying \"$fromFlavor\" to \"$destinationFile\"")
recursiveCopy(fromVariant, destinationFile)
}
}
tasks.named("prepareComposeResourcesTaskForCommonMain").configure {
dependsOn("copyKmpResources")
}
I'm implementing the android flavor strategy to my project. To do that I've added new source and resource dirs.
Please don't! The projects source sets are not for the flavoring. The flavoring as you described is the android specific thing. If you need to have different logic/resources then use gradle modules
sourceSets {
commonMain {
kotlin.srcDir("...") // <- adds new source directory to the kotlin source set
resources.srcDir("...") // <- meaningless for the kotlin multiplatform
}
}
Scenario
I'm implementing the android flavor strategy to my project. To do that I've added new source and resource dirs. Let's focus in the commomMain:
In fact, I added new sources to each flavors (flavor1 and falvor2) and variantes(flavor1Debug, flavor1Release, flavor2Debug, flavor2Release)
The object
variant
above is gotten according to gradle command been runned.Problem
All the rouserces added in src/commonFlavor1/composeResources/drawable are not being processed and added to
Res.drawable
.Workarrouund
As a way to "solve" this I've create a task to copy the necessary resources to
build/generated/compose/resourceGenerator/preparedResources/commonMain/composeResources/
.Unfortunatelly It doesn't work right after a
./gradlew clean
I don't know whyAffected platforms
Versions
To Reproduce
Steps to reproduce the behavior:
sourceSets { commonMain { resources.srcDir("src/commonFlavor1/composeResources") } }
src/commonFlavor1/composeResources/drawable/icon.xml
Expected behavior
As I've added a new source dir to
sourceSets -> commomMain -> resources
, I expected that the new resources can be used normally.Additional context
Adding a new source dir to
.kt
files has worked as expected, only the composeResources doesn't.I hope I'm not duplicating a bug, I search for similar issues but I wasn't able to find
Tks.
The text was updated successfully, but these errors were encountered: