Looks for settings.gradle


(Weihung) #1

The document in section 20.4, there is say how to looks for setting.gradle:
If you execute Gradle from within a project with no settings.gradle file, Gradle looks for a settings.gradle file in the following way:

  • It looks in a directory called master which has the same nesting level as the current dir.
  • If not found yet, it searches parent directories.
  • If not found yet, the build is executed as a single project build.

I think that means
if (found settings.gradle) {
build
} else if (found settings.gradle in master) {
build
} else if (found settings.gradle in parent) {
build
} else {
single project build
}

So I do some test.
Test 1:
.
├── master
│ └── settings.gradle
├── project1
│ └── build.gradle
└── project2
└── build.gradle

settings.gradle is
include ‘:…:project1’, ':…:project2’
println ‘settings.gradle in master’

Run ‘gradle projects’ in project1, it’s response:
settings.gradle in master
This is project1
This is project2
:…:project1:projects

Test2:
.
├── master
│ └── settings.gradle
├── project1
│ └── build.gradle
├── project2
│ └── build.gradle
└── settings.gradle

settings.gradle in mastert is
include ‘:…:project1’, ':…:project2’
println ‘settings.gradle in master’

settings.gradle in root is
include ‘:project1’, ':project2’
println ‘settings.gradle in parent’

Run ‘gradle projects’ in project1, it’s response:
settings.gradle in parent
This is project1
This is project2
:project1:projects

Why gradle not use master/settings.gralde in test2?