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

spring Boot源码编译

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

下载:git clone [email protected]:spring-projects/spring-boot.git,建议下载release版本,不会出现奇奇怪怪的错误

Spring-boot 2.3.x源码基于Gradle编译过程详解_第1张图片

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编译过程详解_第2张图片

Spring-boot 2.3.x源码基于Gradle编译过程详解_第3张图片
Spring-boot 2.3.x源码基于Gradle编译过程详解_第4张图片

3.开始编译

Spring-boot 2.3.x源码基于Gradle编译过程详解_第5张图片

至此撒花编译成功!

Spring-boot 2.3.x源码基于Gradle编译过程详解_第6张图片

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

Spring-boot 2.3.x源码基于Gradle编译过程详解_第7张图片

到此这篇关于Spring-boot 2.3.x源码基于Gradle编译过程详解的文章就介绍到这了,更多相关Spring-boot 2.3.x源码内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

你可能感兴趣的:(Spring-boot 2.3.x源码基于Gradle编译过程详解)