# multiplatform

Jiri Bruchanov

09/21/2023, 7:56 AM
Hi, anyone who could help ? I'm building small gradle plugin which generates kt code. I'm facing following error
Copy code
Reason: 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
task reference though, using simple
returns null even if I do that in
block. What would be the correct way to do it ?
trying also use
Copy code
val provider = target.tasks.register("compileCommonMainKotlinMetadata")
provider.configure { t ->
that fails unfortunately later when actual KMP tries to create the task
Copy code
Cannot add task 'compileCommonMainKotlinMetadata' as a task with that name already exists.

Adam S

09/22/2023, 9:29 AM
What's your Gradle config? I would guess that you're adding a new directory, something like
? 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:

Jiri Bruchanov

09/22/2023, 9:33 AM
yup, that's what I was doing... I didn't realise I can pass the task itself as a "source dir" which the issue
👍 1