I turned on `org.gradle.configureondemand=true`, b...
# gradle
s
I turned on
org.gradle.configureondemand=true
, 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
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
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
Hmm, is this the only option? It looks very overkill and complicated to implement
v
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. :-)