为什么 -b 选项禁用 settings.gradle?

Why -b option disables settings.gradle?

11.5. Selecting which build to execute 表示:

When you run the gradle command, it looks for a build file in the current directory. You can use the -b option to select another build file. If you use -b option then settings.gradle file is not used.

我有一个多模块项目,其 settings.gradle 包含子模块。

我该如何解决这个问题?

-c 不是您要找的吗?使用 -c 你可以传递一个 settings.gradle 文件。

我正在回答进一步的问题。

实际上,当我应该使用 -b 选项时,-c 选项根本不起作用。

$ gradle -b _build.gradle -c settings.gradle

文件说

Alternatively, you can use the -p option to specify the project directory to use. For multi-project builds you should use -p option instead of -b option.

我必须创建一个目录并使用 -p 选项。

$ ls -F
gradlep/    sub1/    sub2/
$ ls gradlep
build.gradle settings.xml

不过,我可以在根目录中调用gradle

$ gradle -p gradlep build