Jiri Bruchanov
09/21/2023, 7:56 AMReason: Task ':shared:compileCommonMainKotlinMetadata' uses this output of task ':shared:generateCode' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
So trying to add a dependency/relation to specify the order between KMP task and my generateCode task.
I'm not sure how to get :shared:compileCommonMainKotlinMetadata
task reference though,
using simple target.tasks.findByName
returns null even if I do that in afterEvaluate
block.
What would be the correct way to do it ?val provider = target.tasks.register("compileCommonMainKotlinMetadata")
provider.configure { t ->
t.mustRunAfter(generateCodeTaskProvider)
}
that fails unfortunately later when actual KMP tries to create the task
Cannot add task 'compileCommonMainKotlinMetadata' as a task with that name already exists.
Adam S
09/22/2023, 9:29 AMsrcDir("build/generated-sources/kotlin")
?
If that's the case, then instead you'll want to pass a task reference instead, and that task has an output directory. That way Gradle will automatically know it needs to run the task in order for the sources to be ready, and additionally any tasks that use those sources will understand the requirement.
Try taking a look at this answer: https://stackoverflow.com/a/74771876/4161471Jiri Bruchanov
09/22/2023, 9:33 AM