By default, build scripts of parent projects get evaluated before build scripts of child projects. Hence the property doesn't exist at the time that you check for its existence.
There are several solutions. One is to set the property's value in the parent script's suprojects
block, based on the name or path of the current project (e.g. if (project.path == ":foo") {...} else {...}
). Another is to move the body of the subprojects
block (or at least the part that makes use of the property) into a script plugin and apply that plugin from every build script (e.g. apply from: "$rootDir/gradle/foo.gradle"
). This gives you a chance to set the property's value before applying the script plugin. Yet another solution (which I personally try to avoid) is to keep things as they are and call evaluationDependsOnChildren()
before accessing the property from the parent build script.