1、gradle无法下载
无法下载或者下载缓慢原因众所周知,可以使用腾讯镜像代理下载
2、grandle编译spring源码
使用版本:spring-framework-5.0.2.RELEASE
1)使用gradle版本不要太高 我使用的是gradle-4.4.1
否则会报错
FAILURE: Build failed with an exception. * Where: Build file 'D:\spring-framework-5.0.2.RELEASE\build.gradle' line: 18 * What went wrong: An exception occurred applying plugin request [id: 'com.gradle.build-scan', version: '1.8'] > Failed to apply plugin [id 'com.gradle.build-scan'] > This version of Gradle requires version 2.0.2 of the build scan plugin or later. Please see https://gradle.com/scans/help/gradle-incompatible-plugin-version for more information.
问题参照:https://www.cnblogs.com/hujinshui/p/10372595.html
2)gradle配置
修改spring-framework-5.0.2.RELEASE\gradle\wrapper 目录下gradle-wrapper.properties文件
#distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip
distributionUrl=file:///D:/gradle-4.4.1.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
注意 file:///D:/gradle-4.4.1.zip 一定是/(正斜杠)路径分隔符 否则报Could not create parent directory for lock file XXXX 的错
3)修改为阿里镜像
spring-framework-5.0.2.RELEASE\build.gradle
buildscript {
repositories {
maven { url "https://maven.aliyun.com/repository/public/"}
maven { url "https://maven.aliyun.com/repository/central"}
maven { url "https://maven.aliyun.com/repository/spring-plugin/"}
maven { url "https://maven.aliyun.com/repository/gradle-plugin/"}
}
dependencies {
classpath("io.spring.gradle:propdeps-plugin:0.0.8")
classpath("io.spring.gradle:docbook-reference-plugin:0.3.1")
classpath("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16")
classpath("org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.7")
}
}
我使用的是阿里云仓库新地址,仓库服务更加细化,需要将spring-plugin/、gradle-plugin/ 这两个引入,否则会报找不到pom
3、编译
在idea引入spring源码工程,执行gradlew bulid 或者 reimport gradle project 等待执行