, but now I have an issue when building my app. I create a task, and have that task depend on a task from another project. That task doesn't exist yet.
Copy code
val myTask: Task = tasks.create("myTask") {
val projectB = project(":projectB")
dependsOn(projectB.tasks["jsBrowserProductionWebpack"])
doLast {
...
}
}
What is the correct way to work around this?
h
hfhbd
12/29/2022, 10:22 AM
I have the same problem. I think (!), you should depend on the outputs of
Copy code
jsBrowserProductionWebpack
as your inputs only, because Gradle is able to resolve the tasks creating these outputs
v
Vampire
12/29/2022, 11:42 AM
You should never use other projects tasks like that even without configure on demand. It is an unsafe anti-pattern. Find at https://docs.gradle.org/current/userguide/cross_project_publications.html how to properly and safely share outputs between projects. Configure on demand is incubation and needs decouple projects to work properly which is exactly what you not have by that configuration.
h
hfhbd
12/29/2022, 11:53 AM
Hmm, is this the only option? It looks very overkill and complicated to implement
v
Vampire
12/29/2022, 12:11 PM
There is a simpler way with some restrictions and a full proper way. Both are documented there and yes, those are the only safe and proper options I'm aware of. But they are not that complicated once you got the grasp. :-)