Why settings.gradle file is not used when -b is sp

2019-04-13 01:34发布

问题:

From Gradle User Guide we can read that

You can use the -b option to select another build file. If you use -b option then settings.gradle file is not used.

So lets have:

-Example      #Project root
 --src
   --main
   --test
 --build.gradle
 --second.gradle #Second build script
 --settings.gradle
 

What is the purpose of this? If I want to try something different with my multiproject build I create another script file - second.gradle and put it in the same directory. But want old settings.gradle file to include my subprojects.

If I execute my gradle comands when I am in the root directory of Example project for ex:

gradle  -b second.gradle clean build

Why Gradle does not use settings.gradle file? To protect itself when specified build file is not in the same dir, because Gradle will looks for settings.gradle in the direcotry of build.gradle file and after that in the parent directory. But they can empty or can be from another project?

回答1:

-b allows to pass a different build script for a single-project build. It is not meant to be used for multi-project builds, where settings.gradle alone determines where build scripts are located.



标签: build gradle