IDEA compilation Spring5 source environment

Recent study spring-framework source code, step on a lot of pits in the process of configuring the source environment, where the configuration process will be recorded for later re-configuration can save time point in time.
Native environment: jdk1.8.0_161, IDEA2019.3.1, Gradle5.6.2, spring -framework-5.1.x, windows10

Gradle installation

Spring-frameworkUse Gradlethe environment to build, so the compiler Springwhen you need to install the source Gradleenvironment, Gradleand Mavensimilar installation are direct download archive -> unpack -> configuration environment variable.

  • Download gradle archive
    into the official website Download: https: //gradle.org/releases/ download the corresponding version, here I downloaded 5.6.2
  • Extracting archive
    extract to your own directory, my directory is D: \ work \ softSave \ gradle -5.6.2
  • Configuration environment variable
  1. Configuring GRADLE_HOME = D: \ work \ softSave \ gradle-5.6.2 (own extract the directory);
  2. Increase% GRADLE_HOME% \ bin in the PATH
  3. Increase GRADLE_USER_HOME environment variable, specify your own gradle download jar package on what, I'm here to configure the D: \ work \ file \ gradle_repo
  4. In the command line input gradle -v, if the following message appears it indicates a successful installation configuration
    Here Insert Picture Description
  • Configuring local repository
    directly installed gradleduring the build when some packets due to network and other resources will be wall download fails, you can configure the global gradle warehouse, I configured Ali cloud repository:
    extract the directory in the init.d gradle New init.gradle file directory, which you can add the following
   allprojects{
   repositories {
       def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
       all { ArtifactRepository repo ->
           if(repo instanceof MavenArtifactRepository){
               def url = repo.url.toString()
               if (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
       }
   }
}

Download Spring-frameworkSource

All projects are located in github above spring, spring-framework of the github link https://github.com/search?q=org%3Aspring-projects+spring&unscoped_q=spring

  • Open the link, select the following items
    Here Insert Picture Description
  • Select the version you want to download the source code, and download or directly to local git clone
    Here Insert Picture Description

Compile source code

  • IEDA into the source in this case can only look at the code can not be found by IDEA click directly into the corresponding class, because the source is required to build gradle
  • Construction of Source:
  1. spring-core, and is spring-aspect project two other modules depends, it is necessary to build these two works
    a. first spring-aspect to the next directory, the command line is built gradle build command, as shown, if there then the bUILD sUCCESSFUL constructed successfully;
    Here Insert Picture Description
    . B into the spring-core directory, a similar operation performed;
  2. Find buildSrc directory under spring-framework directory, run build.gradle file to compile the source code.

Note: The error can occur with this method source code compilation process, if it is wrong to download resources, you need to reconfigure gradle warehouse, if other error, you can try commenting out the appropriate line, mostly test class for errors, can be resolved, Ferguson can drop a variety show to see the source code of the operating compiled by.

Released eight original articles · won praise 3 · Views 840

Guess you like

Origin blog.csdn.net/weixin_40203134/article/details/103212308