Idea compile Spring5.2.x source code

We need to use the 5.2.x version, because the higher version 5.3 requires JDK, jdK8 is no longer available, requirement 13. In order for 5.2.x to compile successfully, you must pay attention to the gradle version. If the version does not meet the requirements of the source code, the compilation will fail. More on that later.


The article directories


preface


Tip: The following is the body of this article, the following cases for reference

Gradle download preparation

Gradle download:Services.gradle.org/distributio…You are advised to download all

I’m using gradle.5.6.4 for spring5.2.x. Look at the following file.





So here’s the introductionDistributionUrl: Once this project introduces idea,idea automatically downloads Gradle based on this path, which is the official default configuration. You can use the local path instead

==distributionBase = GRADLE_USER_HOME Installation path of Gradle ==

Install Gradle

1. Gradle decompresses directly

Distribute the distributionUrl file directly to the gradle-5.6.4-all folder. Distribute the distributionUrl file directly to the gradle-5.6.4-all folder

2. Configure environment variables

== Add %GRADLE_HOME%/bin to path after creating GRADLE_HOME. It = =

Run gradle-v to check whether gradle is successfully configured

3. Configure the domestic mirror

Go to the Gradl e installation directory, create a new init.gradle file in the init.d directory and add the following contents:

allprojects{
    repositories {
        def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
        all { ArtifactRepository repo ->
            def url = repo.url.toString()
            if ((repo instanceof MavenArtifactRepository) && (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com'))) {
                project.logger.lifecycle 'Repository ${repo.url} replaced by $REPOSITORY_URL .'
                remove repo
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}
Copy the code

3, download spring 5.2.x source code and unpack it. Open it with idea Open. There is a note before opening it. Look down, look down. I said it three times.

Download spring5.2.x :github.com/spring-proj… Just download the zip and unzip it locally





== At this time when the project is just opened, IDEA will automatically download gradle configuration according to the project configuration. Once you see the window below, click Cancel, and then IDEA can be configured for our local Gradle ==



Idea Click Settings to configure

Modify gradle/wrapper/gradle-wrapper.properties in the Spring-framework directory. Modify the distributionUrl property and the network address corresponding to the distributionUrl property to a local address. You must download gradle-6.7.1-bin.zip to the local directory first. Add GRADLE_USER_HOME to the environment variable and set it to JAVA_HOME. Gradle files are stored in c:\User\ current User. Gradle files are stored in c:\User\ current User

DistributionUrl =file:/// e:/ gradle-5.6.4-all.zip

Add project Gradle image

Search for current build.gradle repositories in the root directory

Search Repositories adds the following

repositories {
			maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
			maven { url "https://maven.aliyun.com/nexus/content/repositories/jcenter" }
			mavenCentral()
			maven { url "https://repo.spring.io/libs-spring-framework-build" }
			maven { url "https://repo.spring.io/milestone" }
			maven { url "https://repo.spring.io/plugins-release"}}Copy the code



Add the configuration in build.gradle under buildSrc

maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url "https://maven.aliyun.com/nexus/content/repositories/jcenter" }
Copy the code

Configure project SDK





Update download repository dependencies



While we’re waiting, you can have a cigarette. A long wait



It took me 15 minutes…



Wait for IDEA to create an index

1 To compile Spring-OXm select complierTestjava





complete

To compile Spring-core, select complierTestjava



complete

3 Run the build method in the root directory



Compile the complete

test

1 Create a Moudle and select Gradle





2. After clicking Finish, it will automatically help us create the module

3. Modify the build.gradle file, add dependencies, and import files again

Compile (project(); compile(project();":spring-context"))
    compile(project(":spring-beans"))
    compile(project(":spring-core"))
    compile(project(":spring-aop"))
Copy the code



Write in the last

Everything finally not easy to complete, thank you for the key three, forwarding favorites like. If you have any questions, leave a message…

Welcome to follow my wechat official account [Village of apes] to talk about Java interview \

Add my wechat for further communication and learning if the display is frequent, wechat mobile search [codeYuanzhicunup] can be added if there are related technical problems welcome to leave a message to discuss, the public number is mainly used for technology sharing, including often meet test analysis, as well as source code interpretation, micro service framework, technical hot spots, etc..