Gradle默认使用build.gradle作为默认的配置文件文件名。如果我们在build.gradle文件中编写代码,那么我们在运行任务的时候,不需要指定build文件名。我们也可以不使用build.gradle,而用另外的文件名来创建build配置文件。但是更改过后需要在 settings.gradle文件中,给rootProject修改属性值buildFileName:。这样gradle才识别修改后的文件。
在spring setting.gradle文件中的例子:
include "spring-aop"
include "spring-aspects"
include "spring-beans"
include "spring-context"
include "spring-context-support"
include "spring-context-indexer"
include "spring-core"
include "kotlin-coroutines"
project(':kotlin-coroutines').projectDir = file('spring-core/kotlin-coroutines')
include "spring-expression"
include "spring-instrument"
include "spring-jcl"
include "spring-jdbc"
include "spring-jms"
include "spring-messaging"
include "spring-orm"
include "spring-oxm"
include "spring-test"
include "spring-tx"
include "spring-web"
include "spring-webmvc"
include "spring-webflux"
include "spring-websocket"
include "framework-bom"
include "integration-tests"
rootProject.name = "spring"
rootProject.children.each {project ->
project.buildFileName = "${project.name}.gradle" /
}
include 'learn'
配置文件中加入对应buildFileName就万事大吉了。