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就万事大吉了。
本文深入讲解Gradle构建工具的配置细节,包括默认配置文件build.gradle的使用,如何自定义配置文件名称并在settings.gradle中进行设置,确保Gradle能正确识别。同时,提供了大量关于Spring项目模块的include示例。

6万+

被折叠的 条评论
为什么被折叠?



