You’re most likely running into an order of operations problem. If you add some debug prints you’ll probably see that the subprojects block is executed before the subprojects are configured.
subprojects {
println "config $name from root"
...
}
Are you sure you need to do this? If you are just trying to extract common configuration logic then you can do this in a variety of alternative ways. In general, cross-project configuration is frowned upon, it makes builds difficult to read and comprehend.
Here’s one very simply solution: common.gradle
// common build logic
if (project.hasProperty("foo")) {
println "has foo"
}