Spring-boot 2.3.x源码基于Gradle编译过程详解

作者:@遇见O_o 时间:2022-04-07 15:41:36 

spring Boot源码编译

1. git上下拉最新版的spring Boot

下载:git clone git@github.com:spring-projects/spring-boot.git,建议下载release版本,不会出现奇奇怪怪的错误

Spring-boot 2.3.x源码基于Gradle编译过程详解

2.修改下载源,

gradle\wrapper中的配置文件

gradle-wrapper.properties


distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
//这里Gradle换成你自己存放gradle的路径以及gradle的压缩包名
//这里需要注意的是gradle版本问题,尽量高一点儿,就是用了gradle-4.9的版本,导致报错gradle-api plugins问题,还缺包啥的,换了包之后就没问题了
distributionUrl=file:///E:/Gitee_repository/Java_Sources_Code_Study/Spring-Boot-2.3.1/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

buildSrc下的build.gradle


plugins {
id "java-gradle-plugin"
//可能是原有的编译环境,注释掉,否则报错
//id "io.spring.javaformat" version "${javaFormatVersion}"
id "checkstyle"
}

repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url "https://repo.spring.io/plugins-release" }
mavenCentral()
gradlePluginPortal()
maven { url "https://repo.spring.io/release" }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
.......

settings.gradle


pluginManagement {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url "https://repo.spring.io/plugins-release" }
mavenCentral()
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "io.spring.javaformat") {
useModule "io.spring.javaformat:spring-javaformat-gradle-plugin:${requested.version}"
}
}
}
}

gradle.properties


javaFormatVersion=0.0.22
#新增如下配置,解决heap堆内存空间不够问题
gradlePropertiesProp=gradlePropertiesValue
sysProp=shouldBeOverWrittenBySysProp
systemProp.system=systemValue
org.gradle.caching=false
org.gradle.jvmargs=-Xms2048m -Xmx4096m
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.configureondemand=true

根目录下的build.gradle


// 放在第一行
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url "https://repo.spring.io/plugins-release" }
}
}

allprojects {
group "org.springframework.boot"

repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
mavenCentral()
if (!version.endsWith('RELEASE')) {
maven { url "https://repo.spring.io/milestone" }
}
if (version.endsWith('BUILD-SNAPSHOT')) {
maven { url "https://repo.spring.io/snapshot" }
}
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 60, "minutes"
}
}

seetings.gradle


pluginManagement {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
mavenCentral()
gradlePluginPortal()
maven {
url 'https://repo.spring.io/plugins-release'
}
if (version.endsWith('BUILD-SNAPSHOT')) {
maven { url "https://repo.spring.io/snapshot" }
}
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "org.jetbrains.kotlin.jvm") {
useVersion "${kotlinVersion}"
}
if (requested.id.id == "org.jetbrains.kotlin.plugin.spring") {
useVersion "${kotlinVersion}"
}
}
}
}

2. idea导入

在编译的时候点击取消,配置idea

Spring-boot 2.3.x源码基于Gradle编译过程详解

Spring-boot 2.3.x源码基于Gradle编译过程详解
Spring-boot 2.3.x源码基于Gradle编译过程详解

3.开始编译

Spring-boot 2.3.x源码基于Gradle编译过程详解

至此撒花编译成功!

Spring-boot 2.3.x源码基于Gradle编译过程详解

不过后面还有好长时间的检测,不知道是什么鬼??

Spring-boot 2.3.x源码基于Gradle编译过程详解

来源:https://blog.csdn.net/buhuiguowang/article/details/110700585

标签:Spring-boot,2.3.x,Gradle,编译
0
投稿

猜你喜欢

  • springboot jackson配置教程

    2021-12-10 20:47:16
  • Java锁擦除与锁粗化概念和使用详解

    2022-02-09 15:32:30
  • Springboot基础学习之初识SpringBoot

    2022-08-18 08:48:59
  • Java 常见排序算法代码分享

    2023-09-30 08:23:09
  • C#使用NPOI上传excel

    2022-05-20 14:46:22
  • springboot2.0如何通过fastdfs实现文件分布式上传

    2022-03-20 16:49:24
  • Android HorizontalScrollView滑动与ViewPager切换案例详解

    2023-06-05 00:48:27
  • Java简单计时的实现案例(可以用来限时循环)

    2023-02-01 21:39:19
  • 解析Tomcat 6、7在EL表达式解析时存在的一个Bug

    2023-07-03 22:02:50
  • Android开发中Activity创建跳转及传值的方法

    2021-06-11 19:13:35
  • c# 颜色选择控件的实现代码

    2022-04-27 07:22:58
  • Java实现酒店客房管理系统

    2023-11-21 06:58:38
  • Java中的异常处理(try,catch,finally,throw,throws)

    2021-07-29 16:45:12
  • Freemarker如何生成树形导航菜单(递归)

    2023-02-24 13:52:16
  • Android通过记住密码功能学习数据存储类SharedPreferences详解及实例

    2023-05-21 21:37:49
  • Java的Spring框架下的AOP编程模式示例

    2023-11-02 00:52:25
  • Spring boot热部署devtools过程解析

    2022-06-21 13:12:09
  • C++异常处理 try,catch,throw,finally的用法

    2021-08-21 21:29:55
  • 利用DrawerLayout和触摸事件分发实现抽屉侧滑效果

    2022-11-09 04:45:51
  • Java包装类原理与用法实例分析

    2022-08-15 19:51:44
  • asp之家 软件编程 m.aspxhome.com