There are a number of issues with this. Your biggest issue could be ordering the configuration. That is, the tasks may not exist yet when this code runs in the root project. A better way to do this would be the following:
subprojects {
tasks.all {
if (it.name.startsWith('cur')) {
myTask.dependsOn it
}
}
}
tasks.all is a domain object collection that allows you to register a config hook for all tasks that have already been created as well as any new task that gets created later.