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