This message was deleted.
# community-support
s
This message was deleted.
e
I just set up forwarding tasks in the included builds, e.g.
Copy code
// build.gradle.kts
tasks.register("foo") {
    dependsOn(gradle.includedBuilds.map { it.task(":foo") })
}
Copy code
// included/build.gradle.kts
tasks.register("foo") {
    dependsOn(subprojects.map { "${it.path}:foo" })
}
👀 1
a
thanks, that partially works. Do you have an idea if not all subprojects have
task :foo
?
e
well that's up to how you set up your subprojects, but at that point it has nothing to do with included builds
a
maybe
Copy code
tasks.register("foo") {
    dependsOn(
        subprojects.map { subproject ->
            subproject.tasks.matching { it.name == "foo" }
        }
    )
}
v
Definitely not 🙂
Besides that using
tasks.matching
like that completely disables task-configuration avoidance, you should not reach into the subprojects model like that. That's why ephemient did it with the string-y dependency.
a
and combined with https://stackoverflow.com/a/69179714/, seems to be working well
Copy code
// modules/build.gradle.kts

// workaround for running <https://github.com/gradle/gradle/issues/22335>
tasks.addRule("Pattern: subprojectTasks_
<TASK>") {
    val taskName = this
    val taskPrefix = "subprojectTasks_"

    if (startsWith(taskPrefix)) {
        task(taskName) {
            val buildTaskName = taskName.removePrefix(taskPrefix).replaceFirstChar(Char::lowercase)
            val subprojectTasks = subprojects.map { subproject ->
                subproject.tasks.matching { it.name == buildTaskName }
            }
            dependsOn(subprojectTasks)
        }
    }
}
which is basically the same functionality as https://github.com/gradle/gradle/issues/22335 👍
v
This has exactly the same problems I just explained, so don't do this or you majorly hurt your builds