Idea is stuck for a long time, but the buid (compilation) does not move — the solution (applicable to Maven and gradle) and the whole process of positioning

Time:2021-9-21

[outside the nickname!]

The final solution is not complex, the key isWhen encountering problems, how to analyze layer by layer, multiple paths of trial and error, and finally solve the problem”——One of the core competitiveness of senior code farmers

 

background

Today, I finished a project in the last two months. Happy duck, idea switched the code to other historical projects and continued to move forward. Eh, what’s the situation? The original compilation is good. This time, the compilation doesn’t move for more than 5 minutes – it was only more than 10 seconds or more than 20 seconds. What’s the situation

 Idea is stuck for a long time, but the buid (compilation) does not move -- the solution (applicable to Maven and gradle) and the whole process of positioning

 

Multi-path attempt, step by step, and finally solve the problem

  • Path a

Cause analysis – is it because other software is opened more and computer CPU and memory are less free, so build is relatively slow, which is occasionally encountered in history

Try it – close the resource consuming software and wait patiently

 

Specific operation:

Close office, vscode, VMware and chrome browsers, and only keep 5 tab pages

Happily read the company’s architecture documents for 10 minutes. Look back and see, eh, what’s the situation? It’s still compiling

 

Conclusion:

Failed — switch other paths quickly


 

  • Path B

Cause analysis – there may be a recent configuration update or an error

Try a way – restart (I think many strange problems can be solved by restarting the software or computer)

 

Specific operation:

Restart idea and wait for 5 minutes. I’ll go and Haisi can’t compile

 

Conclusion:

Fantesy – continue switching other paths


 

  • Path C – critical

Cause analysis – it doesn’t matter if you come from Baidu or Google

Try — Baidu search

 

Specific operation:

Extract the search keyword – “idea compilation for half a day”, baidu(Keyword extraction is very important, which directly affects the quality of search results

Search for a related blog:https://blog.csdn.net/weixin_34850743/article/details/104291937

The paper mentions the temporary solutions and some tentative solutions as follows(Some have tried, others are time-consuming and labor-consuming, so they are not accepted):

  1. Extended idea memory, invalid.
  2. Restart the computer, invalid, it seems that it is not a network problem.
  3. Switch to local warehouse, invalid.
  4. Clear cache and index, invalid.
  5. Delete item, re import, invalid.
  6. Delete the project, download it again, and then import the idea. It is invalid.
  7. Create a new class, add the annotation of the startup class, and add a sysout before the run method. It is invalid.
  8. Close idea, import the project into eclipse, and start. Reopen idea and see if it can be started. It is invalid.
  9. Uninstall and reinstall.
    1. Uninstall and reinstall the current version 2019.3, which is invalid
    2. Reinstall on March 6, 2018, invalid.
  10. Edit the configuration, remove the build and change it to MVN compile, which can be used temporarily

Continue to the comments area:

Network disabled, this is good. Unplug the network cable decisively. The compilation is a little smoother, but an error is reported, as follows(Key information: error downloading dependent package):

 

Conclusion:

I know the general problem – it should be caused by the recent upgrade of gandle from 5.1 to 6.5  “Caused by super slow download of dependent packages”(downloading jar dependent packages and GitHub source code abroad has been very slow recently). I think that the recent project needs to download Python offline packages on the pypi official website – a speed of a few KB / s or more than 10 KB / s


 

  • Path D – Final Solution

Cause analysis——“Caused by super slow download of dependent packages”

Try method – configure Alibaba cloud domestic image or company server image

 

Specific operation:

%GRADLE_ USER_ Home% \. Gradle directory, addinit.gradlewritingFill in the following contents(Logic: switch different download paths according to the starting address of the dependent package):

allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public/'
        def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter/'
        def ALIYUN_GOOGLE_URL = 'https://maven.aliyun.com/repository/google/'
        def ALIYUN_GRADLE_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin/'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
                if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL."
                    remove repo
                }
                if (url.startsWith('https://plugins.gradle.org/m2/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL."
                    remove repo
                }
            }
        }
        maven { url ALIYUN_REPOSITORY_URL }
        maven { url ALIYUN_JCENTER_URL }
        maven { url ALIYUN_GOOGLE_URL }
        maven { url ALIYUN_GRADLE_PLUGIN_URL }
    }
}

Conclusion:

The compilation succeeded in more than 10 seconds. It’s a happy duck, as shown in the following figure:

Note:

(1) Configuring alicloud images globallyhttps://blog.csdn.net/lj402159806/article/details/78422953

2) Alibaba cloud image warehouse official website and description – updates and changes to the official website need to be synchronized in timehttps://maven.aliyun.com/mvn/guide

 

The copyright of this article belongs to the author and the blog park. Reprint is welcome, but this statement must be retained without the consent of the author, and the original connection must be given in an obvious position on the article page, otherwise the right to investigate legal responsibility is reserved.

*******************************************************************************************

Limited energy and too many ideas. Just focus on one thing

  • I’m just a procedural ape.Write the code well within 5 years, deliberate every word in the technical blog, and adhere to zero copy and originality
  • The significance of blogging is to exercise logical organization, deepen the systematic understanding of knowledge, and exercise writing. If it happens to be helpful to others, it’s really a happy thing

*******************************************************************************************

Recommended Today

Seven Python code review tools recommended

althoughPythonLanguage is one of the most flexible development languages at present, but developers often abuse its flexibility and even violate relevant standards. So PythoncodeThe following common quality problems often occur: Some unused modules have been imported Function is missing arguments in various calls The appropriate format indentation is missing Missing appropriate spaces before and after […]