编译spring源码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lianjiaokeji/article/details/82177236

spring源码编译流程:

Spring5 源码下载

第 一 步 :
https://github.com/spring-projects/spring-framework/archive/v5.0.2.RELEASE.zip
第二步: 下载 gradle
http://downloads.gradle.org/distributions/gradle-4.1-bin.zip
第三步: 解压,配置 GRADLE_HOME 和 Path
第四步: 验证 gradle -v, 环境变量是否正确
第五步: 点击Sping源码下 gradlew.bat 构建项目

导入项目遇见问题:

1.No such property: immutableValues for class: org.gradle.api.internal.tasks.DefaultTaskDependency

修改:spring-beans.gradle

注释掉这两行代码
//def deps = compileGroovy.taskDependencies.immutableValues + compileGroovy.taskDependencies.mutableValues
//compileGroovy.dependsOn = deps - 'compileJava'

2.Could not find method useJUnitPlatform()

注释:spring-test.gradle中这行代码
//  useJUnitPlatform {
//    includeEngines 'junit-jupiter'
//    excludeTags 'failing-test-case'
// }

3.spring core核心代码报错

这里写图片描述

这里写图片描述
解决方案:
cmd进入该目录
E:\>cd xxx\spring-framework\spring-core
执行:
gradle build会生成两个核心jar包

这里写图片描述

4.kotlin编译导致的问题

问题一

org.gradle.api.CircularReferenceException: Circular dependency between the following tasks:
:spring-beans:compileGroovy
\--- :spring-beans:compileJava
     \--- :spring-beans:compileKotlin
          \--- :spring-beans:compileGroovy (*)

编译github的最新spring源码发现该问题,主要是kotlin版本不一致导致的
这里写图片描述

这里写图片描述
问题二

Error:(434, 19) Kotlin: Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'

解决方法
这里写图片描述

5.Aspects模块代码编译出错

https://jira.spring.io/browse/SPR-12103
https://youtrack.jetbrains.com/issue/IDEA-64446

猜你喜欢

转载自blog.csdn.net/lianjiaokeji/article/details/82177236