This message was deleted.
# community-support
s
This message was deleted.
v
You should wire it to neither task. Instead you should define the generation task's output as source directory, then all tasks that need sources automatically get the necessary task dependency. Otherwise, you need to add explicit task dependencies to all tasks that need the sources and that could be added by arbitrary plugins.
Copy code
val yourGenerationTask by tasks.registering...

sourceSets {
    main {
        java {
            srcDir(yourGenerationTask)
        }
    }
}
j
I am going to try that, thank you! I guess it would work with Kotlin APIs too? thinking in the kotlin custom dsl for KMP as root source sets don't work on kmp
v
🤷‍♂️
j
Executing
./gradlew compileKotlin --dry-run
should show the task if it was added as
srcDir
?
v
Probably
For Kotlin/JVM this was handled in https://youtrack.jetbrains.com/issue/KT-16764/Kotlin-Gradle-plugin-should-replicate-task-dependencies-of-Java-source-directories it seems. Maybe they did not properly do it for KMP
j
yeah, on kotlin jvm, the Gradle official source sets are mapped to the Kotlin ones, but with kmp the sets are empty but the kotlin ones have the info
v
If it does not work on those, I'd say you should report that, so they can fix that.
👍 1
j
I am getting a stack overflow because I am getting the kotlin generated dir from the kotlin src dirs, and I am setting the task as input of a kotlin source set. Is there any strategy for this use case? I would want to avoid hardcoding the generated dir and instead filter based on the existents ones
v
I'm not fully getting. Do you mean your generation depends on the other source files?
j
From other part, it is added to the kotlin source dirs of the
main
set the directory
build/generated/main
(or whatever) In order to be able to use it on the task, I am getting it from the kotlin extension too. This mix is generating a stack overflow
v
I'm still not fully getting. But it sounds like you try to generate into a common folder. Don't do that. Never, ever, ever, ever have tasks with overlapping outputs.
👍 1