美文网首页
IDEA maven 加速

IDEA maven 加速

作者: 谭冉冉 | 来源:发表于2018-10-18 22:30 被阅读37次

    方法1 到~/.gradle/目录下创建一个 init.gradle 文件,把下面这些复制进去就 ok 了

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

    方法2 ~/.gradle/gradle.properties 在这个文件里可以设置代理

    systemProp.https.proxyPort=1087
    systemProp.http.proxyHost=127.0.0.1
    org.gradle.daemon=true
    systemProp.https.proxyHost=127.0.0.1
    org.gradle.configureondemand=true
    systemProp.http.proxyPort=1087
    

    相关文章

      网友评论

          本文标题:IDEA maven 加速

          本文链接:https://www.haomeiwen.com/subject/uslezftx.html