Subproject cannot access variable in master project (flat) unless folder is named "master"

Hello,

I am just getting started with Gradle.
I am experimenting with a scenario of this type with 4 projects
Project 1 "utility"
a standalone gradle project with reusable code
settings.gradle: deleted

Project 2 "solution"
The “root” project of a flat multi module build
settings.gradle:
rootProject.name = 'master’
includeFlat 'utility’
includeFlat 'jar’
includeFlat ‘war’

build.gradle
def getSrcDir(project) {
return project.file(srcDirName)
}

Project 3 "jar"
A component of "solution"
settings.gradle: deleted

Project 4 "war"
A component of solution
settings.gradle: deleted

build.gradle
task showme {
doLast {
// Use inherited property
println 'srcDirName: ’ + srcDirName

    // Use inherited method
    File srcDir = getSrcDir(project)
    println 'srcDir: ' + rootProject.relativePath(srcDir)
}

}

The problem is that unless the directory/folder of project 2 is named “master” (and not solution), the command gradle task showme ran from project 4 (war) would fail with
Could not get unknown property ‘srcDirName’ for task ‘:showme’ of type org.gradle.api.DefaultTask.

It clearly show that when I am in the sub project, the only way to identify the root project is by folder name (that has to be master)

Is there any other way to find/include the master project when running the build from a sub project?

Should I alternative look to composite build?
What I want to achieve is to be able to build deploy a subproject one by one using utilities,procedures and informations stored in project 1 and 2. At the same I want to be able to perform the same operation on all modules (potentially 100) by running the build from the master projecty.
The above mentioned error prevents me to implemente this build structure

I have found it best to name the projects after the folders in which they reside. So when the rootProject’s settings state that its name = ‘master’, I would also name its folder ‘master’. And if you want to have the folder named ‘solution’, then also update the rootProject’s setting to state its name = ‘solution’.

Does that help?

I 100% agree with you. But that is exacly the problem
the directory name for the root project of flat multi project must “master”.
Failing to do so makes it impossible for subproject to identify the root project when commands are run from the sub project.
I need the confirmation that the directory must be named “master” or not?
Thanks