亲宝软件园·资讯

展开

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

@遇见O_o 人气:0

spring Boot源码编译

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

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

在这里插入图片描述

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

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

3.开始编译

在这里插入图片描述

至此撒花编译成功!

在这里插入图片描述

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

在这里插入图片描述

加载全部内容

相关教程
猜你喜欢
用户评论