第一章:Gradle 多项目开发概述
- 实际上所谓的多项目指的就是
父子项目
,在实际项目开发中,任何一个庞大的项目为了方便管理肯定会拆分为若干个不同的子模块,而后每一个子模块可以单独实现某些功能,例如:公共的组件模块、业务模块、WEB 前端模块,这些子模块需要进行一些特定依赖的使用。 - 如果现在分别创建这些 Gradle 项目,则会遇到如下的问题:
- ① Gradle 中一定需要进行大量的结构配置。
- ② 需要引入大量的第三方的依赖库。
- ③ 还需要考虑到一些任务的配置(Junit5、编码问题)。
- 所以考虑到这些重复性问题,那么就要将所有和一个项目有关的代码配置进行统一的有效管理,这样就形成了
父子结构
。

- 在这样的项目结构之中,公共的父项目可以定义所有项目中的核心属性以及所有与之相关的核心依赖库的配置,而子项目只需要直接继承父项目中的相关结构即可进行正常的项目开发。
第二章:创建 Gradle 公共父项目
2.1 概述
- 如果现在要想进行项目开发,则一定需要将所有的依赖以及公共的任务放在公共的父项目之中,随后子模块可以继承这些配置。
2.2 项目创建


2.3 配置属性
- 如果要想使用项目,还需要设置项目的组织信息、版本等。

2.4 Gradle 属性
- 在 Gradle 项目之中创建一个
gradle.properties
文件,这个文件的主要目的是定义一些 Gradle 项目的公共属性,即定义一系列的变量,内容如下:
project_group=com.github.fairy.era
project_version=1.0
project_jdk=1.8

2.6 依赖管理
- 所有的依赖一定要保存在
dependencies.gradle
配置文件中,本次由于需要创建 WEB 项目,在之前的基础上追加了 Servlet、JSP 等依赖,内容如下:
// 定义所有要使用的版本号
ext.versions = [
junitJupiterVersion: '5.8.2',
druidVersion : '1.2.8',
servletVersion : '4.0.1',
jspVersion : '2.3.3',
jstlVersion : '1.2'
]
// 定义所有的依赖库
ext.libraries = [
/* junit5 */
'junit-jupiter': "org.junit.jupiter:junit-jupiter:${versions.junitJupiterVersion}",
/* druid */
'druid' : "com.alibaba:druid:${versions.druidVersion}",
/* servlet */
'servlet' : "javax.servlet:javax.servlet-api:${versions.servletVersion}",
/* jsp */
'jsp' : "javax.servlet.jsp:javax.servlet.jsp-api:${versions.jspVersion}",
/* jstl */
'jstl' : "javax.servlet.jsp.jstl:jstl:${versions.jstlVersion}"
]

2.7 GradleWrapper
- 修改 gradle/wrapper/gradle-wrapper.properties 配置文件,修改当前使用的 Gradle 版本:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
# 修改版本号
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2.8 Gradle 配置
- 修改 build.gradle 配置文件,在这个配置文件里面定义相关的环境,需要注意的是,此时依赖库通过外部文件导入,同时也可以直接使用 gradle.properties 里面定义的属性内容,内容如下:
apply from: 'dependencies.gradle' // 导入依赖配置文件
def env = System.getProperty('env') ?: 'dev' // 获取 env 环境属性
allprojects { // 所有模块/项目的通用配置
apply plugin: 'idea'
apply plugin: 'java' // 如果要想让 JDK 版本配置生效,必须要导入此插件
apply plugin: 'java-library'
sourceCompatibility = project_jdk // 通过 gradle.properties 文件导入
targetCompatibility = project_jdk // 通过 gradle.properties 文件导入
group project_group // 通过 gradle.properties 文件导入
version project_version // 通过 gradle.properties 文件导入
}
project(':erp-web') { // 设置子项目的配置,独享配置
dependencies {
compileOnly(
libraries.'servlet',
libraries.'jsp',
)
}
}
subprojects { // 子模块/项目的统一配置,subprojects 配置项中定义的内容都是可以被子项目直接继承的(大部分)
repositories { // 定义所有依赖的下载仓库,如果不定义,每个子模块都需要单独定义
maven {
url 'https://maven.aliyun.com/repository/public/'
}
mavenCentral()
}
dependencies { // 依赖配置
testImplementation(
libraries.'junit-jupiter'
)
implementation(
libraries.'druid',
libraries.'jstl'
)
}
test {
useJUnitPlatform()
}
sourceSets { // 建立源代码的目录集合
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources', "src/main/profiles/${env}"]
}
}
test {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
tasks.each { task ->
if (task.name.contains('test')) { // 如果发现有 test 任务,就跳过
task.enabled = true // 当前任务是否执行,如果为 true ,表示执行;反之,不执行
}
}
}
// 最终生成的 jar 文件名称:baseName-version-classifier.extension
task sourceJar(type: Jar, dependsOn: classes) { // 定义一个源代码的打包任务,并依赖于 classes 这种 Gradle 内置的任务
archiveClassifier.set 'sources' // 文件的分类
from sourceSets.main.allSource // 所有源代码的读取路径
}
task javaDocTask(type: Javadoc) {
source sourceSets.main.allJava // 定义所有的 Java 源代码的路径
}
tasks.withType(Javadoc) { // 文档生成一定要有乱码处理
options.encoding = "UTF-8"
}
tasks.withType(JavaCompile) { // 针对程序编译的任务进行配置
options.encoding = "UTF-8"
}
// 指定编码格式
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
task javaDocJar(type: Jar, dependsOn: javaDocTask) { // 先生成 javadoc,才可以打包
archiveClassifier.set 'javadoc' // 文件的分类
from javaDocTask.destinationDir // 通过 javaDocTask 任务中找到目标路径
}
artifacts { // 最终的打包操作任务
archives sourceJar
archives javaDocJar
}
}
第三章:Gradle 创建 Java 子模块
3.1 概述
- 有了父项目之后对于子模块的定义就比较简单了,大部分的子模块都可以直接使用父项目中定义的依赖库,同时很多的任务也都可以在子模块中进行,本次创建一个纯粹的 Java 模块。
3.2 模块创建
- 在 erp 项目中创建一个 erp-service 子模块,此模块的类型为 java 。


3.3 子模块的配置
- 由于现在给出的是子模块,所有相关的项目属性都能够被 IDEA 自动识别。


- 由于在 erp 父项目的 build.gradle 配置文件中定义了源代码的目录结构,所以此时就可以非常清楚的发现,子模块直接存在对应的源代码目录(都是根据配置自动生成的)。
3.4 子模块的配置
- 修改 build.gradle 配置文件,这个文件其实现在并不需要做太多的配置。
plugins {
id 'java'
}
3.5 编写代码
- 编写 IMessageService 业务接口以及业务的实现子类。
package com.github.fairy.era.service;
/**
* @author 许大仙
* @version 1.0
* @since 2021-12-21 08:41
*/
public interface IMessageService {
/**
* echo 方法
*
* @param msg 要进行回应处理的消息主体
* @return 处理完成后的消息内容
*/
String echo(String msg);
}
package com.github.fairy.era.service.impl;
import com.github.fairy.era.service.IMessageService;
/**
* @author 许大仙
* @version 1.0
* @since 2021-12-21 08:42
*/
public class MessageServiceImpl implements IMessageService {
@Override
public String echo(String msg) {
return "hello " + msg;
}
}
3.6 代码测试
- 编写测试代码对 IMessageService 接口功能进行测试。
package com.github.era.fairy.service;
import com.github.fairy.era.service.IMessageService;
import com.github.fairy.era.service.impl.MessageServiceImpl;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* @author 许大仙
* @version 1.0
* @since 2021-12-21 08:43
*/
public class MessageServiceTest {
@Test
public void test() {
IMessageService messageService = new MessageServiceImpl();
Assertions.assertEquals("hello Gradle", messageService.echo("Gradle"));
}
}
3.7 父项目控制
- 对于测试,父项目存在有有一个是否执行测试代码的控制操作:
gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
tasks.each { task ->
if (task.name.contains('test')) { // 如果发现有 test 任务,就跳过
task.enabled = false // 当前任务不执行
}
}
}
- 对于当前的测试任务的控制操作,已经确定被子模块直接继承了,所以子模块里面即便没有编写任何的任务配置,也可以通过父项目的 build.gradle 程序进行整个程序测试代码执行与否的控制。
第四章:Gradle 创建 WEB 子模块
4.1 概述
- 一个项目中最终肯定会有前端的展示功能,所以自然就需要 WEB 模块,需要注意的是,由于此时的父项目之中已经对源代码进行了配置(build.gradle 文件):
sourceSets { // 建立源代码的目录集合
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources', "src/main/profiles/${env}"]
}
}
test {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
- 如果是一个 WEB 项目,还需要在 src/main 下提供一个 webapp 源代码目录,这个目录会由系统自动配置。
4.2 项目创建
- 创建一个 erp-web 项目,这个项目创建的同时一定要选择 Web 插件。


4.3 子模块的配置
- 由于现在给出的是子模块,所有相关的项目属性都能够被 IDEA 自动识别。


- 现在由于在项目中引入了 war 的 Gradle 插件配置,所以会自动生成 src/main/webapp 目录,保存所有的 WEB 程序(当然,如果有需要可以自己创建 WEB-INF/web.xml 配置文件等)。
4.4 子模块的配置
- 由于 erp 父项目中已经配置好了相关的依赖库,所以 erp-web 项目中的 build.gradle 配置文件并不需要配置太多东西,只需要保存插件即可:
plugins {
id 'war'
id 'java'
}
4.5 子模块依赖
- 现在的 erp-web 项目希望可以引用 erp-service 项目中提供的 IMessageService 接口及其实现类进行信息的回应处理,那么这种项目之间的依赖不需要修改 erp 父项目中的配置,修改 build.gradle 文件:
plugins {
id 'war'
id 'java'
}
archivesBaseName = 'erp-web'
dependencies {
implementation(
project(':erp-service') // 引入其他项目中的代码
)
}
4.6 编写代码
- 编写一个 Servlet 的程序,实现信息的回显处理。
package com.github.fairy.era.servlet;
import com.github.fairy.era.service.IMessageService;
import com.github.fairy.era.service.impl.MessageServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author 许大仙
* @version 1.0
* @since 2021-12-28 10:39
*/
@WebServlet(urlPatterns = "/message")
public class MessageServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
IMessageService messageService = new MessageServiceImpl();
String msg = messageService.echo("Gradle");
resp.getWriter().write(msg);
}
}
4.7 项目部署
- 直接将当前的 WEB 项目部署到 Tomcat 之中,随后通过浏览器进行访问。

第五章:Gradle 子模块管理
5.1 概述
- 到现在为止,已经成功创建了 erp 项目,同时在 erp 项目中也存在有若干个模块,那么按照传统的构建工具创建的项目来说,肯定是直接针对于父模块进行代码的编译处理。
5.2 项目编译
- 针对于 erp 项目执行 Gradle 编译操作,执行命令如下:
gradle clean build
5.3 子模块 javadoc 乱码处理
- 当命令执行完毕之后所有相关的子模块里面都会出现 build 目录,并且提供了编译后的程序文件,需要注意的是,此时在执行的时候出现了一些(非正常)错误,这个错误出现在了 erp-web 模块里面,而且全部都和导入的类有关系。

- 对于当前的错误,有些时候是因为编码的关系造成的,但是有些时候也有可能是开发工具造成的,一般来讲,如果是编码造成的原因,可以直接在子模块中的 build.gradle 文件里面进行一些编码的配置,如:配置一个 javadoc 编码
javadoc {
options {
encoding('UTF-8')
charSet 'UTF-8'
author true
version true
title 'erp-web'
}
}
- 如果上述的方式依然不行,那么在使用 Gradle 的时候还有一种乱码处理方式,就是直接在父项目中的 build.gradle 文件里面追加一行集体的编码配置:
[compileJava, compileTestJava,javadoc]*.options*.encoding = 'UTF-8'
- 虽然现在可以生成相应的 javadoc 文件,但是对于 WEB 端来说 javadoc 的意义不是很大,所以可以考虑直接在 erp-web 项目里面忽略掉所有的 javadoc 相关任务,修改 build.gradle 文件:
gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
tasks.each { task ->
if (task.name.contains('javaDoc')) { // 如果发现有 test 任务,就跳过
task.enabled = false // 当前任务不执行
}
}
}
5.4 子模块配置
- 对于当前的 erp 项目来说,所有子模块的配置都是在 subprojects 中进行定义的,除了每一个项目应该具有的一些核心目录之外(src/{main,test}/{java,resources}),实际上又为其追加了 profiles 目录,但是并不是所有的项目都需要这样的定义,那么如果有一些特殊的需求,就需要在子模块中进行配置了,查看 erp 项目中的 build.gradle 文件(因为我们上面已经知道了):
project(':erp-web') { // 设置子项目的配置,独享配置
dependencies {
compileOnly(
libraries.'servlet',
libraries.'jsp',
)
}
gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
tasks.each { task ->
if (task.name.contains('javaDoc')) { // 如果发现有 test 任务,就跳过
task.enabled = false // 当前任务不执行
}
}
}
}
5.5 排除包
- 对于有些模块来说,可能并不需要 servlet 相关的程序包,此时可以采用排除的模式来进行处理,本次以 emp-service 模块为例进行说明(注意:emp-service 模块本身就不包含 servlet 相关的程序包)。
- 修改 emp 项目的 build.gradle 文件:
project(':erp-service') { // 设置子项目的配置,独享配置
configurations {
all.collect { configuration -> // 全局的排除设置
configuration.exclude group: 'javax.servlet'
configuration.exclude group: 'com.alibaba', module: 'druid'
}
}
}

5.6 打包任务配置
- 现在假设 erp-service 模块中需要进行一个打包的处理操作,首先定义一个程序的执行主类:
package com.github.fairy.era;
/**
* @author 许大仙
* @version 1.0
* @since 2021-12-24 15:36
*/
public class GradleMain {
public static void main(String[] args) {
System.out.println("你好啊,Gradle");
}
}
- 随后修改 emp 项目的 build.gradle 文件,给 emp-service 模块追加如下的任务配置:
project(':erp-service') { // 设置子项目的配置,独享配置
configurations {
all.collect { configuration -> // 全局的排除设置
configuration.exclude group: 'javax.servlet'
configuration.exclude group: 'com.alibaba', module: 'druid'
}
}
// 追加任务配置
def mainClassName = 'com.github.fairy.era.GradleMain' // 程序的主类名称
jar {
archivesBaseName = 'gradle' // 生成的 jar 文件名称,如果不写此名称则使用项目名称
manifestContentCharset = 'UTF-8' // 设置整个文件的编码
metadataCharset = 'UTF-8' // 元数据设置编码
manifest {
attributes 'Manifest-Version': getArchiveVersion().getOrNull(), // 程序版本号
'Main-Class': "${mainClassName}",// 程序主类名称
'Implementation-Title': 'hello-gradle',// 程序主类名称
'Implementation-Version': archiveVersion // 版本编号
}
into('lib') { // 将程序锁需要的第三方组件包配置到 lib 目录之中
from configurations.compileClasspath
}
}
}
5.7 温馨提示
- 在大部分的 Gradle 项目开发过程之中,实际上并不一定需要写如此繁琐的操作,最为常见的子模块的定义形式:
project(':erp-web') { } // 设置子项目的配置,独享配置
project(':erp-service') { } // 设置子项目的配置,独享配置
5.8 子模块信息
- 所有的子模块都是在父项目中进行统一管理的,那么如果有需要也可以直接列出当前项目中的所有子模块。
- 程序执行命令:
gradle -q projects
17:11:15: 正在执行 'projects -q'…
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'erp'
+--- Project ':erp-service'
\--- Project ':erp-web'
To see a list of the tasks of a project, run gradle <project-path>:tasks
For example, try running gradle :erp-service:tasks
17:11:16: 执行完成 'projects -q'。
5.9 子模块的依赖信息
- 所有项目中子模块对应的依赖信息都可以直接获取。
- 程序执行命令:
gradle -q dependencies erp-service:dependencies erp-web:dependencies
17:14:53: 正在执行 'dependencies erp-service:dependencies erp-web:dependencies -q'…
------------------------------------------------------------
Root project
------------------------------------------------------------
------------------------------------------------------------
Project :erp-service
------------------------------------------------------------
------------------------------------------------------------
Project :erp-web
------------------------------------------------------------
annotationProcessor - Annotation processors and their dependencies for source set 'main'.
annotationProcessor - Annotation processors and their dependencies for source set 'main'.
annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies
No dependencies
No dependencies
api - API dependencies for source set 'main'. (n)
api - API dependencies for source set 'main'. (n)
api - API dependencies for source set 'main'. (n)
No dependencies
No dependencies
No dependencies
apiElements - API elements for main. (n)
No dependencies
archives - Configuration for archive artifacts. (n)
No dependencies
compileClasspath - Compile classpath for source set 'main'.
apiElements - API elements for main. (n)
No dependencies
apiElements - API elements for main. (n)
No dependencies
archives - Configuration for archive artifacts. (n)
No dependencies
compileClasspath - Compile classpath for source set 'main'.
archives - Configuration for archive artifacts. (n)
No dependencies
compileClasspath - Compile classpath for source set 'main'.
No dependencies
compileOnly - Compile only dependencies for source set 'main'. (n)
No dependencies
default - Configuration for default artifacts. (n)
No dependencies
implementation - Implementation only dependencies for source set 'main'. (n)
No dependencies
runtimeClasspath - Runtime classpath of source set 'main'.
No dependencies
runtimeElements - Elements of runtime for main. (n)
No dependencies
runtimeOnly - Runtime only dependencies for source set 'main'. (n)
No dependencies
testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies
testCompileClasspath - Compile classpath for source set 'test'.
No dependencies
testCompileOnly - Compile only dependencies for source set 'test'. (n)
No dependencies
testImplementation - Implementation only dependencies for source set 'test'. (n)
No dependencies
testRuntimeClasspath - Runtime classpath of source set 'test'.
No dependencies
testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
\--- javax.servlet.jsp.jstl:jstl:1.2
compileOnly - Compile only dependencies for source set 'main'. (n)
No dependencies
default - Configuration for default artifacts. (n)
No dependencies
implementation - Implementation only dependencies for source set 'main'. (n)
+--- com.alibaba:druid:1.2.8 (n)
\--- javax.servlet.jsp.jstl:jstl:1.2 (n)
runtimeClasspath - Runtime classpath of source set 'main'.
\--- javax.servlet.jsp.jstl:jstl:1.2
runtimeElements - Elements of runtime for main. (n)
No dependencies
runtimeOnly - Runtime only dependencies for source set 'main'. (n)
No dependencies
testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies
testCompileClasspath - Compile classpath for source set 'test'.
+--- javax.servlet.jsp.jstl:jstl:1.2
\--- org.junit.jupiter:junit-jupiter:5.8.2
+--- org.junit:junit-bom:5.8.2
| +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
| \--- org.junit.platform:junit-platform-commons:1.8.2 (c)
+--- org.junit.jupiter:junit-jupiter-api:5.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| +--- org.opentest4j:opentest4j:1.2.0
| +--- org.junit.platform:junit-platform-commons:1.8.2
| | +--- org.junit:junit-bom:5.8.2 (*)
| | \--- org.apiguardian:apiguardian-api:1.1.2
| \--- org.apiguardian:apiguardian-api:1.1.2
\--- org.junit.jupiter:junit-jupiter-params:5.8.2
+--- org.junit:junit-bom:5.8.2 (*)
+--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
\--- org.apiguardian:apiguardian-api:1.1.2
testCompileOnly - Compile only dependencies for source set 'test'. (n)
No dependencies
testImplementation - Implementation only dependencies for source set 'test'. (n)
\--- org.junit.jupiter:junit-jupiter:5.8.2 (n)
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- javax.servlet.jsp.jstl:jstl:1.2
\--- org.junit.jupiter:junit-jupiter:5.8.2
+--- org.junit:junit-bom:5.8.2
| +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-engine:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
| +--- org.junit.platform:junit-platform-commons:1.8.2 (c)
| \--- org.junit.platform:junit-platform-engine:1.8.2 (c)
+--- org.junit.jupiter:junit-jupiter-api:5.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| +--- org.opentest4j:opentest4j:1.2.0
| \--- org.junit.platform:junit-platform-commons:1.8.2
| \--- org.junit:junit-bom:5.8.2 (*)
+--- org.junit.jupiter:junit-jupiter-params:5.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
\--- org.junit.jupiter:junit-jupiter-engine:5.8.2
+--- org.junit:junit-bom:5.8.2 (*)
+--- org.junit.platform:junit-platform-engine:1.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| +--- org.opentest4j:opentest4j:1.2.0
| \--- org.junit.platform:junit-platform-commons:1.8.2 (*)
\--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
No dependencies
(c) - dependency constraint
(*) - dependencies omitted (listed previously)
(n) - Not resolved (configuration is not meant to be resolved)
A web-based, searchable dependency report is available by adding the --scan option.
+--- javax.servlet:javax.servlet-api:4.0.1
+--- javax.servlet.jsp:javax.servlet.jsp-api:2.3.3
+--- com.alibaba:druid:1.2.8
+--- javax.servlet.jsp.jstl:jstl:1.2
\--- project :erp-service
compileOnly - Compile only dependencies for source set 'main'. (n)
+--- javax.servlet:javax.servlet-api:4.0.1 (n)
\--- javax.servlet.jsp:javax.servlet.jsp-api:2.3.3 (n)
default - Configuration for default artifacts. (n)
No dependencies
implementation - Implementation only dependencies for source set 'main'. (n)
+--- com.alibaba:druid:1.2.8 (n)
+--- javax.servlet.jsp.jstl:jstl:1.2 (n)
\--- project erp-service (n)
providedCompile - Additional compile classpath for libraries that should not be part of the WAR archive.
No dependencies
providedRuntime - Additional runtime classpath for libraries that should not be part of the WAR archive.
No dependencies
runtimeClasspath - Runtime classpath of source set 'main'.
+--- com.alibaba:druid:1.2.8
+--- javax.servlet.jsp.jstl:jstl:1.2
\--- project :erp-service
\--- javax.servlet.jsp.jstl:jstl:1.2
runtimeElements - Elements of runtime for main. (n)
No dependencies
runtimeOnly - Runtime only dependencies for source set 'main'. (n)
No dependencies
testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
No dependencies
testCompileClasspath - Compile classpath for source set 'test'.
+--- com.alibaba:druid:1.2.8
+--- javax.servlet.jsp.jstl:jstl:1.2
+--- project :erp-service
\--- org.junit.jupiter:junit-jupiter:5.8.2
+--- org.junit:junit-bom:5.8.2
| +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
| \--- org.junit.platform:junit-platform-commons:1.8.2 (c)
+--- org.junit.jupiter:junit-jupiter-api:5.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| +--- org.opentest4j:opentest4j:1.2.0
| +--- org.junit.platform:junit-platform-commons:1.8.2
| | +--- org.junit:junit-bom:5.8.2 (*)
| | \--- org.apiguardian:apiguardian-api:1.1.2
| \--- org.apiguardian:apiguardian-api:1.1.2
\--- org.junit.jupiter:junit-jupiter-params:5.8.2
+--- org.junit:junit-bom:5.8.2 (*)
+--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
\--- org.apiguardian:apiguardian-api:1.1.2
testCompileOnly - Compile only dependencies for source set 'test'. (n)
No dependencies
testImplementation - Implementation only dependencies for source set 'test'. (n)
\--- org.junit.jupiter:junit-jupiter:5.8.2 (n)
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- com.alibaba:druid:1.2.8
+--- javax.servlet.jsp.jstl:jstl:1.2
+--- project :erp-service
| \--- javax.servlet.jsp.jstl:jstl:1.2
\--- org.junit.jupiter:junit-jupiter:5.8.2
+--- org.junit:junit-bom:5.8.2
| +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-engine:5.8.2 (c)
| +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
| +--- org.junit.platform:junit-platform-commons:1.8.2 (c)
| \--- org.junit.platform:junit-platform-engine:1.8.2 (c)
+--- org.junit.jupiter:junit-jupiter-api:5.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| +--- org.opentest4j:opentest4j:1.2.0
| \--- org.junit.platform:junit-platform-commons:1.8.2
| \--- org.junit:junit-bom:5.8.2 (*)
+--- org.junit.jupiter:junit-jupiter-params:5.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
\--- org.junit.jupiter:junit-jupiter-engine:5.8.2
+--- org.junit:junit-bom:5.8.2 (*)
+--- org.junit.platform:junit-platform-engine:1.8.2
| +--- org.junit:junit-bom:5.8.2 (*)
| +--- org.opentest4j:opentest4j:1.2.0
| \--- org.junit.platform:junit-platform-commons:1.8.2 (*)
\--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
No dependencies
(c) - dependency constraint
(*) - dependencies omitted (listed previously)
(n) - Not resolved (configuration is not meant to be resolved)
A web-based, searchable dependency report is available by adding the --scan option.
17:14:53: 执行完成 'dependencies erp-service:dependencies erp-web:dependencies -q'。
5.10 总结
- 所有在 Gradle 项目中的配置信息都可以通过父项目进行统一管理的,而所有子模块的信息也是可以通过父项目直接获取的。