libres
libres copied to clipboard
Able to work with multiple source dir
Current state of kotlin multiplatform not support "flavors\builttypes". But its not trouble. Just enough do more sources by conditions
val commonMain by getting {
if(BUILD_TYPE == BUILD_TYPE.STAGE) {
val variantSrc = "${project.rootDir}/app/src/variantMainStage/kotlin"
val variantResources = "${project.rootDir}/app/src/variantMainStage/libres"
kotlin.srcDir(variantSrc)
resources.srcDir(variantResources)
} else {
// default
val variantSrc = "${project.rootDir}/app/src/variantMainDemo/kotlin"
val variantResources = "${project.rootDir}/app/src/variantMainDemo/libres"
kotlin.srcDir(variantSrc)
resources.srcDir(variantResources)
}
...
}
Its work. We have same set of dependencies that containt commonMain and look like a habitual androids flavor setup
But libres dont see an alternative resources. Do you khow how to fix it?
Done. About pr. The plugin takes into account all sources of initial resources and merges their values. in the case of image files, the file will be added to the share or replaced when the filenames match. Strings. If the string line exists, it will be replaced, if not, it will be added. The first source is commonMain.
Sorry for long reply. I looked at your PR. Looks good, but I have another idea with a more customizable API. It will require a little more code in the project's build.gradle, but at the same time it will avoid "crutches" inside the library for such implementation of flavors (and less changes in the library).
It might look like this
tasks.withType(LibresStringGenerationTask::class) {
inputDirectory.add(file("src/variantDemoMain/libres/strings"))
}
What do you think?
I'm not sure, it's like overwriting a resource file when only the lines inside the file need to be overridden like in pr.
The logic is the same as in your PR, only without automatic finding but with ability to flexibly add files and directories with resources, wherever they are located
My PR does merge xml to single resource file and override lines inside. Your proposal will rewrite a file. Not lines.
mutableAccumulator.getOrPut(lang, ::mutableMapOf).putAll(list.associateBy { it.name })
I think its difference cases. We can add a flag to settings like a separateResources = true / false. It could resolve the inconsistency