第一章:Gradle 多项目开发概述

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

1.png

  • 在这样的项目结构之中,公共的父项目可以定义所有项目中的核心属性以及所有与之相关的核心依赖库的配置,而子项目只需要直接继承父项目中的相关结构即可进行正常的项目开发。

第二章:创建 Gradle 公共父项目

2.1 概述

  • 如果现在要想进行项目开发,则一定需要将所有的依赖以及公共的任务放在公共的父项目之中,随后子模块可以继承这些配置。

2.2 项目创建

  • 直接利用 IDEA 工具创建一个项目:erp 。

2.png

3.png

2.3 配置属性

  • 如果要想使用项目,还需要设置项目的组织信息、版本等。

4.png

2.4 Gradle 属性

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

5.png

2.6 依赖管理

  • 所有的依赖一定要保存在 dependencies.gradle 配置文件中,本次由于需要创建 WEB 项目,在之前的基础上追加了 Servlet、JSP 等依赖,内容如下:
  1. // 定义所有要使用的版本号
  2. ext.versions = [
  3. junitJupiterVersion: '5.8.2',
  4. druidVersion : '1.2.8',
  5. servletVersion : '4.0.1',
  6. jspVersion : '2.3.3',
  7. jstlVersion : '1.2'
  8. ]
  9. // 定义所有的依赖库
  10. ext.libraries = [
  11. /* junit5 */
  12. 'junit-jupiter': "org.junit.jupiter:junit-jupiter:${versions.junitJupiterVersion}",
  13. /* druid */
  14. 'druid' : "com.alibaba:druid:${versions.druidVersion}",
  15. /* servlet */
  16. 'servlet' : "javax.servlet:javax.servlet-api:${versions.servletVersion}",
  17. /* jsp */
  18. 'jsp' : "javax.servlet.jsp:javax.servlet.jsp-api:${versions.jspVersion}",
  19. /* jstl */
  20. 'jstl' : "javax.servlet.jsp.jstl:jstl:${versions.jstlVersion}"
  21. ]

6.png

2.7 GradleWrapper

  • 修改 gradle/wrapper/gradle-wrapper.properties 配置文件,修改当前使用的 Gradle 版本:
  1. distributionBase=GRADLE_USER_HOME
  2. distributionPath=wrapper/dists
  3. # 修改版本号
  4. distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
  5. zipStoreBase=GRADLE_USER_HOME
  6. zipStorePath=wrapper/dists

2.8 Gradle 配置

  • 修改 build.gradle 配置文件,在这个配置文件里面定义相关的环境,需要注意的是,此时依赖库通过外部文件导入,同时也可以直接使用 gradle.properties 里面定义的属性内容,内容如下:
  1. apply from: 'dependencies.gradle' // 导入依赖配置文件
  2. def env = System.getProperty('env') ?: 'dev' // 获取 env 环境属性
  3. allprojects { // 所有模块/项目的通用配置
  4. apply plugin: 'idea'
  5. apply plugin: 'java' // 如果要想让 JDK 版本配置生效,必须要导入此插件
  6. apply plugin: 'java-library'
  7. sourceCompatibility = project_jdk // 通过 gradle.properties 文件导入
  8. targetCompatibility = project_jdk // 通过 gradle.properties 文件导入
  9. group project_group // 通过 gradle.properties 文件导入
  10. version project_version // 通过 gradle.properties 文件导入
  11. }
  12. project(':erp-web') { // 设置子项目的配置,独享配置
  13. dependencies {
  14. compileOnly(
  15. libraries.'servlet',
  16. libraries.'jsp',
  17. )
  18. }
  19. }
  20. subprojects { // 子模块/项目的统一配置,subprojects 配置项中定义的内容都是可以被子项目直接继承的(大部分)
  21. repositories { // 定义所有依赖的下载仓库,如果不定义,每个子模块都需要单独定义
  22. maven {
  23. url 'https://maven.aliyun.com/repository/public/'
  24. }
  25. mavenCentral()
  26. }
  27. dependencies { // 依赖配置
  28. testImplementation(
  29. libraries.'junit-jupiter'
  30. )
  31. implementation(
  32. libraries.'druid',
  33. libraries.'jstl'
  34. )
  35. }
  36. test {
  37. useJUnitPlatform()
  38. }
  39. sourceSets { // 建立源代码的目录集合
  40. main {
  41. java {
  42. srcDirs = ['src/main/java']
  43. }
  44. resources {
  45. srcDirs = ['src/main/resources', "src/main/profiles/${env}"]
  46. }
  47. }
  48. test {
  49. java {
  50. srcDirs = ['src/test/java']
  51. }
  52. resources {
  53. srcDirs = ['src/test/resources']
  54. }
  55. }
  56. }
  57. gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
  58. tasks.each { task ->
  59. if (task.name.contains('test')) { // 如果发现有 test 任务,就跳过
  60. task.enabled = true // 当前任务是否执行,如果为 true ,表示执行;反之,不执行
  61. }
  62. }
  63. }
  64. // 最终生成的 jar 文件名称:baseName-version-classifier.extension
  65. task sourceJar(type: Jar, dependsOn: classes) { // 定义一个源代码的打包任务,并依赖于 classes 这种 Gradle 内置的任务
  66. archiveClassifier.set 'sources' // 文件的分类
  67. from sourceSets.main.allSource // 所有源代码的读取路径
  68. }
  69. task javaDocTask(type: Javadoc) {
  70. source sourceSets.main.allJava // 定义所有的 Java 源代码的路径
  71. }
  72. tasks.withType(Javadoc) { // 文档生成一定要有乱码处理
  73. options.encoding = "UTF-8"
  74. }
  75. tasks.withType(JavaCompile) { // 针对程序编译的任务进行配置
  76. options.encoding = "UTF-8"
  77. }
  78. // 指定编码格式
  79. [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
  80. task javaDocJar(type: Jar, dependsOn: javaDocTask) { // 先生成 javadoc,才可以打包
  81. archiveClassifier.set 'javadoc' // 文件的分类
  82. from javaDocTask.destinationDir // 通过 javaDocTask 任务中找到目标路径
  83. }
  84. artifacts { // 最终的打包操作任务
  85. archives sourceJar
  86. archives javaDocJar
  87. }
  88. }

第三章:Gradle 创建 Java 子模块

3.1 概述

  • 有了父项目之后对于子模块的定义就比较简单了,大部分的子模块都可以直接使用父项目中定义的依赖库,同时很多的任务也都可以在子模块中进行,本次创建一个纯粹的 Java 模块。

3.2 模块创建

  • 在 erp 项目中创建一个 erp-service 子模块,此模块的类型为 java 。

7.png

8.png

3.3 子模块的配置

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

9.png

10.png

  • 由于在 erp 父项目的 build.gradle 配置文件中定义了源代码的目录结构,所以此时就可以非常清楚的发现,子模块直接存在对应的源代码目录(都是根据配置自动生成的)。

3.4 子模块的配置

  • 修改 build.gradle 配置文件,这个文件其实现在并不需要做太多的配置。
  1. plugins {
  2. id 'java'
  3. }

3.5 编写代码

  • 编写 IMessageService 业务接口以及业务的实现子类。
  1. package com.github.fairy.era.service;
  2. /**
  3. * @author 许大仙
  4. * @version 1.0
  5. * @since 2021-12-21 08:41
  6. */
  7. public interface IMessageService {
  8. /**
  9. * echo 方法
  10. *
  11. * @param msg 要进行回应处理的消息主体
  12. * @return 处理完成后的消息内容
  13. */
  14. String echo(String msg);
  15. }
  1. package com.github.fairy.era.service.impl;
  2. import com.github.fairy.era.service.IMessageService;
  3. /**
  4. * @author 许大仙
  5. * @version 1.0
  6. * @since 2021-12-21 08:42
  7. */
  8. public class MessageServiceImpl implements IMessageService {
  9. @Override
  10. public String echo(String msg) {
  11. return "hello " + msg;
  12. }
  13. }

3.6 代码测试

  • 编写测试代码对 IMessageService 接口功能进行测试。
  1. package com.github.era.fairy.service;
  2. import com.github.fairy.era.service.IMessageService;
  3. import com.github.fairy.era.service.impl.MessageServiceImpl;
  4. import org.junit.jupiter.api.Assertions;
  5. import org.junit.jupiter.api.Test;
  6. /**
  7. * @author 许大仙
  8. * @version 1.0
  9. * @since 2021-12-21 08:43
  10. */
  11. public class MessageServiceTest {
  12. @Test
  13. public void test() {
  14. IMessageService messageService = new MessageServiceImpl();
  15. Assertions.assertEquals("hello Gradle", messageService.echo("Gradle"));
  16. }
  17. }

3.7 父项目控制

  • 对于测试,父项目存在有有一个是否执行测试代码的控制操作:
  1. gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
  2. tasks.each { task ->
  3. if (task.name.contains('test')) { // 如果发现有 test 任务,就跳过
  4. task.enabled = false // 当前任务不执行
  5. }
  6. }
  7. }
  • 对于当前的测试任务的控制操作,已经确定被子模块直接继承了,所以子模块里面即便没有编写任何的任务配置,也可以通过父项目的 build.gradle 程序进行整个程序测试代码执行与否的控制。

第四章:Gradle 创建 WEB 子模块

4.1 概述

  • 一个项目中最终肯定会有前端的展示功能,所以自然就需要 WEB 模块,需要注意的是,由于此时的父项目之中已经对源代码进行了配置(build.gradle 文件):
  1. sourceSets { // 建立源代码的目录集合
  2. main {
  3. java {
  4. srcDirs = ['src/main/java']
  5. }
  6. resources {
  7. srcDirs = ['src/main/resources', "src/main/profiles/${env}"]
  8. }
  9. }
  10. test {
  11. java {
  12. srcDirs = ['src/test/java']
  13. }
  14. resources {
  15. srcDirs = ['src/test/resources']
  16. }
  17. }
  18. }
  • 如果是一个 WEB 项目,还需要在 src/main 下提供一个 webapp 源代码目录,这个目录会由系统自动配置。

4.2 项目创建

  • 创建一个 erp-web 项目,这个项目创建的同时一定要选择 Web 插件。

11.png

12.png

4.3 子模块的配置

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

13.png

14.png

  • 现在由于在项目中引入了 war 的 Gradle 插件配置,所以会自动生成 src/main/webapp 目录,保存所有的 WEB 程序(当然,如果有需要可以自己创建 WEB-INF/web.xml 配置文件等)。

4.4 子模块的配置

  • 由于 erp 父项目中已经配置好了相关的依赖库,所以 erp-web 项目中的 build.gradle 配置文件并不需要配置太多东西,只需要保存插件即可:
  1. plugins {
  2. id 'war'
  3. id 'java'
  4. }

4.5 子模块依赖

  • 现在的 erp-web 项目希望可以引用 erp-service 项目中提供的 IMessageService 接口及其实现类进行信息的回应处理,那么这种项目之间的依赖不需要修改 erp 父项目中的配置,修改 build.gradle 文件:
  1. plugins {
  2. id 'war'
  3. id 'java'
  4. }
  5. archivesBaseName = 'erp-web'
  6. dependencies {
  7. implementation(
  8. project(':erp-service') // 引入其他项目中的代码
  9. )
  10. }

4.6 编写代码

  • 编写一个 Servlet 的程序,实现信息的回显处理。
  1. package com.github.fairy.era.servlet;
  2. import com.github.fairy.era.service.IMessageService;
  3. import com.github.fairy.era.service.impl.MessageServiceImpl;
  4. import javax.servlet.ServletException;
  5. import javax.servlet.annotation.WebServlet;
  6. import javax.servlet.http.HttpServlet;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9. import java.io.IOException;
  10. /**
  11. * @author 许大仙
  12. * @version 1.0
  13. * @since 2021-12-28 10:39
  14. */
  15. @WebServlet(urlPatterns = "/message")
  16. public class MessageServlet extends HttpServlet {
  17. @Override
  18. protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  19. this.doPost(req, resp);
  20. }
  21. @Override
  22. protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  23. resp.setContentType("text/html;charset=UTF-8");
  24. IMessageService messageService = new MessageServiceImpl();
  25. String msg = messageService.echo("Gradle");
  26. resp.getWriter().write(msg);
  27. }
  28. }

4.7 项目部署

  • 直接将当前的 WEB 项目部署到 Tomcat 之中,随后通过浏览器进行访问。

15.png

第五章:Gradle 子模块管理

5.1 概述

  • 到现在为止,已经成功创建了 erp 项目,同时在 erp 项目中也存在有若干个模块,那么按照传统的构建工具创建的项目来说,肯定是直接针对于父模块进行代码的编译处理。

5.2 项目编译

  • 针对于 erp 项目执行 Gradle 编译操作,执行命令如下:
  1. gradle clean build

5.3 子模块 javadoc 乱码处理

  • 当命令执行完毕之后所有相关的子模块里面都会出现 build 目录,并且提供了编译后的程序文件,需要注意的是,此时在执行的时候出现了一些(非正常)错误,这个错误出现在了 erp-web 模块里面,而且全部都和导入的类有关系。

16.png

  • 对于当前的错误,有些时候是因为编码的关系造成的,但是有些时候也有可能是开发工具造成的,一般来讲,如果是编码造成的原因,可以直接在子模块中的 build.gradle 文件里面进行一些编码的配置,如:配置一个 javadoc 编码
  1. javadoc {
  2. options {
  3. encoding('UTF-8')
  4. charSet 'UTF-8'
  5. author true
  6. version true
  7. title 'erp-web'
  8. }
  9. }
  • 如果上述的方式依然不行,那么在使用 Gradle 的时候还有一种乱码处理方式,就是直接在父项目中的 build.gradle 文件里面追加一行集体的编码配置:
  1. [compileJava, compileTestJava,javadoc]*.options*.encoding = 'UTF-8'
  • 虽然现在可以生成相应的 javadoc 文件,但是对于 WEB 端来说 javadoc 的意义不是很大,所以可以考虑直接在 erp-web 项目里面忽略掉所有的 javadoc 相关任务,修改 build.gradle 文件:
  1. gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
  2. tasks.each { task ->
  3. if (task.name.contains('javaDoc')) { // 如果发现有 test 任务,就跳过
  4. task.enabled = false // 当前任务不执行
  5. }
  6. }
  7. }

5.4 子模块配置

  • 对于当前的 erp 项目来说,所有子模块的配置都是在 subprojects 中进行定义的,除了每一个项目应该具有的一些核心目录之外(src/{main,test}/{java,resources}),实际上又为其追加了 profiles 目录,但是并不是所有的项目都需要这样的定义,那么如果有一些特殊的需求,就需要在子模块中进行配置了,查看 erp 项目中的 build.gradle 文件(因为我们上面已经知道了):
  1. project(':erp-web') { // 设置子项目的配置,独享配置
  2. dependencies {
  3. compileOnly(
  4. libraries.'servlet',
  5. libraries.'jsp',
  6. )
  7. }
  8. gradle.taskGraph.whenReady { // 在所有的操作准备好之后触发
  9. tasks.each { task ->
  10. if (task.name.contains('javaDoc')) { // 如果发现有 test 任务,就跳过
  11. task.enabled = false // 当前任务不执行
  12. }
  13. }
  14. }
  15. }

5.5 排除包

  • 对于有些模块来说,可能并不需要 servlet 相关的程序包,此时可以采用排除的模式来进行处理,本次以 emp-service 模块为例进行说明(注意:emp-service 模块本身就不包含 servlet 相关的程序包)。
  • 修改 emp 项目的 build.gradle 文件:
  1. project(':erp-service') { // 设置子项目的配置,独享配置
  2. configurations {
  3. all.collect { configuration -> // 全局的排除设置
  4. configuration.exclude group: 'javax.servlet'
  5. configuration.exclude group: 'com.alibaba', module: 'druid'
  6. }
  7. }
  8. }

17.png

5.6 打包任务配置

  • 现在假设 erp-service 模块中需要进行一个打包的处理操作,首先定义一个程序的执行主类:
  1. package com.github.fairy.era;
  2. /**
  3. * @author 许大仙
  4. * @version 1.0
  5. * @since 2021-12-24 15:36
  6. */
  7. public class GradleMain {
  8. public static void main(String[] args) {
  9. System.out.println("你好啊,Gradle");
  10. }
  11. }
  • 随后修改 emp 项目的 build.gradle 文件,给 emp-service 模块追加如下的任务配置:
  1. project(':erp-service') { // 设置子项目的配置,独享配置
  2. configurations {
  3. all.collect { configuration -> // 全局的排除设置
  4. configuration.exclude group: 'javax.servlet'
  5. configuration.exclude group: 'com.alibaba', module: 'druid'
  6. }
  7. }
  8. // 追加任务配置
  9. def mainClassName = 'com.github.fairy.era.GradleMain' // 程序的主类名称
  10. jar {
  11. archivesBaseName = 'gradle' // 生成的 jar 文件名称,如果不写此名称则使用项目名称
  12. manifestContentCharset = 'UTF-8' // 设置整个文件的编码
  13. metadataCharset = 'UTF-8' // 元数据设置编码
  14. manifest {
  15. attributes 'Manifest-Version': getArchiveVersion().getOrNull(), // 程序版本号
  16. 'Main-Class': "${mainClassName}",// 程序主类名称
  17. 'Implementation-Title': 'hello-gradle',// 程序主类名称
  18. 'Implementation-Version': archiveVersion // 版本编号
  19. }
  20. into('lib') { // 将程序锁需要的第三方组件包配置到 lib 目录之中
  21. from configurations.compileClasspath
  22. }
  23. }
  24. }

5.7 温馨提示

  • 在大部分的 Gradle 项目开发过程之中,实际上并不一定需要写如此繁琐的操作,最为常见的子模块的定义形式:
  1. project(':erp-web') { } // 设置子项目的配置,独享配置
  2. project(':erp-service') { } // 设置子项目的配置,独享配置

5.8 子模块信息

  • 所有的子模块都是在父项目中进行统一管理的,那么如果有需要也可以直接列出当前项目中的所有子模块。
  • 程序执行命令:
  1. gradle -q projects
  • 程序执行结果:
  1. 17:11:15: 正在执行 'projects -q'
  2. ------------------------------------------------------------
  3. Root project
  4. ------------------------------------------------------------
  5. Root project 'erp'
  6. +--- Project ':erp-service'
  7. \--- Project ':erp-web'
  8. To see a list of the tasks of a project, run gradle <project-path>:tasks
  9. For example, try running gradle :erp-service:tasks
  10. 17:11:16: 执行完成 'projects -q'

5.9 子模块的依赖信息

  • 所有项目中子模块对应的依赖信息都可以直接获取。
  • 程序执行命令:
  1. gradle -q dependencies erp-service:dependencies erp-web:dependencies
  • 程序执行结果:
  1. 17:14:53: 正在执行 'dependencies erp-service:dependencies erp-web:dependencies -q'
  2. ------------------------------------------------------------
  3. Root project
  4. ------------------------------------------------------------
  5. ------------------------------------------------------------
  6. Project :erp-service
  7. ------------------------------------------------------------
  8. ------------------------------------------------------------
  9. Project :erp-web
  10. ------------------------------------------------------------
  11. annotationProcessor - Annotation processors and their dependencies for source set 'main'.
  12. annotationProcessor - Annotation processors and their dependencies for source set 'main'.
  13. annotationProcessor - Annotation processors and their dependencies for source set 'main'.
  14. No dependencies
  15. No dependencies
  16. No dependencies
  17. api - API dependencies for source set 'main'. (n)
  18. api - API dependencies for source set 'main'. (n)
  19. api - API dependencies for source set 'main'. (n)
  20. No dependencies
  21. No dependencies
  22. No dependencies
  23. apiElements - API elements for main. (n)
  24. No dependencies
  25. archives - Configuration for archive artifacts. (n)
  26. No dependencies
  27. compileClasspath - Compile classpath for source set 'main'.
  28. apiElements - API elements for main. (n)
  29. No dependencies
  30. apiElements - API elements for main. (n)
  31. No dependencies
  32. archives - Configuration for archive artifacts. (n)
  33. No dependencies
  34. compileClasspath - Compile classpath for source set 'main'.
  35. archives - Configuration for archive artifacts. (n)
  36. No dependencies
  37. compileClasspath - Compile classpath for source set 'main'.
  38. No dependencies
  39. compileOnly - Compile only dependencies for source set 'main'. (n)
  40. No dependencies
  41. default - Configuration for default artifacts. (n)
  42. No dependencies
  43. implementation - Implementation only dependencies for source set 'main'. (n)
  44. No dependencies
  45. runtimeClasspath - Runtime classpath of source set 'main'.
  46. No dependencies
  47. runtimeElements - Elements of runtime for main. (n)
  48. No dependencies
  49. runtimeOnly - Runtime only dependencies for source set 'main'. (n)
  50. No dependencies
  51. testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
  52. No dependencies
  53. testCompileClasspath - Compile classpath for source set 'test'.
  54. No dependencies
  55. testCompileOnly - Compile only dependencies for source set 'test'. (n)
  56. No dependencies
  57. testImplementation - Implementation only dependencies for source set 'test'. (n)
  58. No dependencies
  59. testRuntimeClasspath - Runtime classpath of source set 'test'.
  60. No dependencies
  61. testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
  62. No dependencies
  63. A web-based, searchable dependency report is available by adding the --scan option.
  64. \--- javax.servlet.jsp.jstl:jstl:1.2
  65. compileOnly - Compile only dependencies for source set 'main'. (n)
  66. No dependencies
  67. default - Configuration for default artifacts. (n)
  68. No dependencies
  69. implementation - Implementation only dependencies for source set 'main'. (n)
  70. +--- com.alibaba:druid:1.2.8 (n)
  71. \--- javax.servlet.jsp.jstl:jstl:1.2 (n)
  72. runtimeClasspath - Runtime classpath of source set 'main'.
  73. \--- javax.servlet.jsp.jstl:jstl:1.2
  74. runtimeElements - Elements of runtime for main. (n)
  75. No dependencies
  76. runtimeOnly - Runtime only dependencies for source set 'main'. (n)
  77. No dependencies
  78. testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
  79. No dependencies
  80. testCompileClasspath - Compile classpath for source set 'test'.
  81. +--- javax.servlet.jsp.jstl:jstl:1.2
  82. \--- org.junit.jupiter:junit-jupiter:5.8.2
  83. +--- org.junit:junit-bom:5.8.2
  84. | +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
  85. | +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
  86. | +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
  87. | \--- org.junit.platform:junit-platform-commons:1.8.2 (c)
  88. +--- org.junit.jupiter:junit-jupiter-api:5.8.2
  89. | +--- org.junit:junit-bom:5.8.2 (*)
  90. | +--- org.opentest4j:opentest4j:1.2.0
  91. | +--- org.junit.platform:junit-platform-commons:1.8.2
  92. | | +--- org.junit:junit-bom:5.8.2 (*)
  93. | | \--- org.apiguardian:apiguardian-api:1.1.2
  94. | \--- org.apiguardian:apiguardian-api:1.1.2
  95. \--- org.junit.jupiter:junit-jupiter-params:5.8.2
  96. +--- org.junit:junit-bom:5.8.2 (*)
  97. +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
  98. \--- org.apiguardian:apiguardian-api:1.1.2
  99. testCompileOnly - Compile only dependencies for source set 'test'. (n)
  100. No dependencies
  101. testImplementation - Implementation only dependencies for source set 'test'. (n)
  102. \--- org.junit.jupiter:junit-jupiter:5.8.2 (n)
  103. testRuntimeClasspath - Runtime classpath of source set 'test'.
  104. +--- javax.servlet.jsp.jstl:jstl:1.2
  105. \--- org.junit.jupiter:junit-jupiter:5.8.2
  106. +--- org.junit:junit-bom:5.8.2
  107. | +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
  108. | +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
  109. | +--- org.junit.jupiter:junit-jupiter-engine:5.8.2 (c)
  110. | +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
  111. | +--- org.junit.platform:junit-platform-commons:1.8.2 (c)
  112. | \--- org.junit.platform:junit-platform-engine:1.8.2 (c)
  113. +--- org.junit.jupiter:junit-jupiter-api:5.8.2
  114. | +--- org.junit:junit-bom:5.8.2 (*)
  115. | +--- org.opentest4j:opentest4j:1.2.0
  116. | \--- org.junit.platform:junit-platform-commons:1.8.2
  117. | \--- org.junit:junit-bom:5.8.2 (*)
  118. +--- org.junit.jupiter:junit-jupiter-params:5.8.2
  119. | +--- org.junit:junit-bom:5.8.2 (*)
  120. | \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
  121. \--- org.junit.jupiter:junit-jupiter-engine:5.8.2
  122. +--- org.junit:junit-bom:5.8.2 (*)
  123. +--- org.junit.platform:junit-platform-engine:1.8.2
  124. | +--- org.junit:junit-bom:5.8.2 (*)
  125. | +--- org.opentest4j:opentest4j:1.2.0
  126. | \--- org.junit.platform:junit-platform-commons:1.8.2 (*)
  127. \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
  128. testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
  129. No dependencies
  130. (c) - dependency constraint
  131. (*) - dependencies omitted (listed previously)
  132. (n) - Not resolved (configuration is not meant to be resolved)
  133. A web-based, searchable dependency report is available by adding the --scan option.
  134. +--- javax.servlet:javax.servlet-api:4.0.1
  135. +--- javax.servlet.jsp:javax.servlet.jsp-api:2.3.3
  136. +--- com.alibaba:druid:1.2.8
  137. +--- javax.servlet.jsp.jstl:jstl:1.2
  138. \--- project :erp-service
  139. compileOnly - Compile only dependencies for source set 'main'. (n)
  140. +--- javax.servlet:javax.servlet-api:4.0.1 (n)
  141. \--- javax.servlet.jsp:javax.servlet.jsp-api:2.3.3 (n)
  142. default - Configuration for default artifacts. (n)
  143. No dependencies
  144. implementation - Implementation only dependencies for source set 'main'. (n)
  145. +--- com.alibaba:druid:1.2.8 (n)
  146. +--- javax.servlet.jsp.jstl:jstl:1.2 (n)
  147. \--- project erp-service (n)
  148. providedCompile - Additional compile classpath for libraries that should not be part of the WAR archive.
  149. No dependencies
  150. providedRuntime - Additional runtime classpath for libraries that should not be part of the WAR archive.
  151. No dependencies
  152. runtimeClasspath - Runtime classpath of source set 'main'.
  153. +--- com.alibaba:druid:1.2.8
  154. +--- javax.servlet.jsp.jstl:jstl:1.2
  155. \--- project :erp-service
  156. \--- javax.servlet.jsp.jstl:jstl:1.2
  157. runtimeElements - Elements of runtime for main. (n)
  158. No dependencies
  159. runtimeOnly - Runtime only dependencies for source set 'main'. (n)
  160. No dependencies
  161. testAnnotationProcessor - Annotation processors and their dependencies for source set 'test'.
  162. No dependencies
  163. testCompileClasspath - Compile classpath for source set 'test'.
  164. +--- com.alibaba:druid:1.2.8
  165. +--- javax.servlet.jsp.jstl:jstl:1.2
  166. +--- project :erp-service
  167. \--- org.junit.jupiter:junit-jupiter:5.8.2
  168. +--- org.junit:junit-bom:5.8.2
  169. | +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
  170. | +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
  171. | +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
  172. | \--- org.junit.platform:junit-platform-commons:1.8.2 (c)
  173. +--- org.junit.jupiter:junit-jupiter-api:5.8.2
  174. | +--- org.junit:junit-bom:5.8.2 (*)
  175. | +--- org.opentest4j:opentest4j:1.2.0
  176. | +--- org.junit.platform:junit-platform-commons:1.8.2
  177. | | +--- org.junit:junit-bom:5.8.2 (*)
  178. | | \--- org.apiguardian:apiguardian-api:1.1.2
  179. | \--- org.apiguardian:apiguardian-api:1.1.2
  180. \--- org.junit.jupiter:junit-jupiter-params:5.8.2
  181. +--- org.junit:junit-bom:5.8.2 (*)
  182. +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
  183. \--- org.apiguardian:apiguardian-api:1.1.2
  184. testCompileOnly - Compile only dependencies for source set 'test'. (n)
  185. No dependencies
  186. testImplementation - Implementation only dependencies for source set 'test'. (n)
  187. \--- org.junit.jupiter:junit-jupiter:5.8.2 (n)
  188. testRuntimeClasspath - Runtime classpath of source set 'test'.
  189. +--- com.alibaba:druid:1.2.8
  190. +--- javax.servlet.jsp.jstl:jstl:1.2
  191. +--- project :erp-service
  192. | \--- javax.servlet.jsp.jstl:jstl:1.2
  193. \--- org.junit.jupiter:junit-jupiter:5.8.2
  194. +--- org.junit:junit-bom:5.8.2
  195. | +--- org.junit.jupiter:junit-jupiter:5.8.2 (c)
  196. | +--- org.junit.jupiter:junit-jupiter-api:5.8.2 (c)
  197. | +--- org.junit.jupiter:junit-jupiter-engine:5.8.2 (c)
  198. | +--- org.junit.jupiter:junit-jupiter-params:5.8.2 (c)
  199. | +--- org.junit.platform:junit-platform-commons:1.8.2 (c)
  200. | \--- org.junit.platform:junit-platform-engine:1.8.2 (c)
  201. +--- org.junit.jupiter:junit-jupiter-api:5.8.2
  202. | +--- org.junit:junit-bom:5.8.2 (*)
  203. | +--- org.opentest4j:opentest4j:1.2.0
  204. | \--- org.junit.platform:junit-platform-commons:1.8.2
  205. | \--- org.junit:junit-bom:5.8.2 (*)
  206. +--- org.junit.jupiter:junit-jupiter-params:5.8.2
  207. | +--- org.junit:junit-bom:5.8.2 (*)
  208. | \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
  209. \--- org.junit.jupiter:junit-jupiter-engine:5.8.2
  210. +--- org.junit:junit-bom:5.8.2 (*)
  211. +--- org.junit.platform:junit-platform-engine:1.8.2
  212. | +--- org.junit:junit-bom:5.8.2 (*)
  213. | +--- org.opentest4j:opentest4j:1.2.0
  214. | \--- org.junit.platform:junit-platform-commons:1.8.2 (*)
  215. \--- org.junit.jupiter:junit-jupiter-api:5.8.2 (*)
  216. testRuntimeOnly - Runtime only dependencies for source set 'test'. (n)
  217. No dependencies
  218. (c) - dependency constraint
  219. (*) - dependencies omitted (listed previously)
  220. (n) - Not resolved (configuration is not meant to be resolved)
  221. A web-based, searchable dependency report is available by adding the --scan option.
  222. 17:14:53: 执行完成 'dependencies erp-service:dependencies erp-web:dependencies -q'

5.10 总结

  • 所有在 Gradle 项目中的配置信息都可以通过父项目进行统一管理的,而所有子模块的信息也是可以通过父项目直接获取的。