moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

How to add a custom path to moko-resources with 0.24.0

Open Burtan opened this issue 1 year ago • 1 comments

Hey,

with moko-resources prior to 0.24.0, moko resources were part of the application resources source path, thus you could add custom pathes to its source set. Now moko-resources has its own resources folder. Can you still add custom pathes? I have used it for generated files like version and licenses information.

Thanks!

Burtan avatar Feb 03 '24 10:02 Burtan

hi @Burtan . yes, we can find way to expose our sourceSet directory to configuration

Alex009 avatar Feb 05 '24 07:02 Alex009

will be fixed in 0.24.0, please check in 0.24.0-alpha-6

ExNDY avatar Apr 17 '24 07:04 ExNDY

will be available in 0.24.0-beta-1 :)

Alex009 avatar Apr 19 '24 14:04 Alex009

@Alex009

> Task :core:compileDebugKotlinAndroid FAILED
e: core/build/generated/kotlin/generateMRandroidMain/com/Res.kt:13:17 Object 'strings' is not abstract and does not implement abstract member public abstract val __platformDetails: ResourcePlatformDetails defined in dev.icerock.moko.resources.ResourceContainer
e: core/build/generated/kotlin/generateMRandroidMain/com/Res.kt:259:17 Object 'plurals' is not abstract and does not implement abstract member public abstract val __platformDetails: ResourcePlatformDetails defined in dev.icerock.moko.resources.ResourceContainer
e: core/build/generated/kotlin/generateMRandroidMain/com/Res.kt:263:17 Object 'images' is not abstract and does not implement abstract member public abstract val __platformDetails: ResourcePlatformDetails defined in dev.icerock.moko.resources.ResourceContainer

ynsok avatar Apr 24 '24 13:04 ynsok

@ynsok any details? Sorry, but this log is useless

ExNDY avatar Apr 24 '24 13:04 ExNDY

Ok, After updating to 0.24.0-beta-1


multiplatformResources {
    resourcesPackage.set("com.******.********")
    resourcesClassName.set("Res")
}
image

@ExNDY What other information do you need?

ynsok avatar Apr 24 '24 14:04 ynsok

@ynsok that problem has no connection with this issue, please create separate issue. What we need: Versions: kotlin, agp, gradle Structure of resources in project. Because we need something recreate your problem on us project. You send only part of log, generated code file, but if this new generated file i need find why code generated without interface realisation

ExNDY avatar Apr 24 '24 14:04 ExNDY

@ExNDY My Bad, I didn't update the resources Generator version. It is working

ynsok avatar Apr 24 '24 14:04 ynsok

Np)

ExNDY avatar Apr 24 '24 15:04 ExNDY

Hey, thanks for addressing this issue! I tried beta-2 with createBuildInfoTask generating resources defined as the tasks output.

afterEvaluate {
    multiplatformResources.resourcesSourceSets["commonMain"].srcDir(createBuildInfoTask)
}

The directory is read correctly and the resource access code is generated. However, the gradle dependency graph is not modified, which means you have to manually trigger the createBuildInfoTask before invoking the moko-resources tasks.

According to JetBrains this should be the way to define task/resource dependencies.

Burtan avatar Apr 28 '24 19:04 Burtan

If you know what should be changed to achieve what you want - sent pr :) Or just add Gradle task dependsOn

Alex009 avatar Apr 30 '24 12:04 Alex009

When using an explicit dependsOn, it often results in complex explicit task dependencies that have to follow (see the linked thread). I have no experience in Gradle plugin coding, but maybe SourceDirectorySet.compiledBy has to be used to tell Gradle that the task processing the resources actually depends on tasks that define the SourceDirectorySet? Maybe the task just has to declare dependency on the SourceDirectorySet?

Burtan avatar May 02 '24 20:05 Burtan