【Gradle】-NO.101.Gradle.1.gradle.1.001-【Gradle Configuration】-(

Style:Gradle

Series:Gradle

Since:2018-09-20

End:2018-09-20

Total Hours:1

Degree Of Diffculty:5

Degree Of Mastery:5

Practical Level:5

Desired Goal:5

Archieve Goal:3

Gerneral Evaluation:3

Writer:kingdelee

Related Links:

http://www.cnblogs.com/kingdelee/

 https://blog.csdn.net/tianqishu11/article/details/78798264

1.

vim ~/.bash_profile 最好修改的是 /etc/profile

source ~/.bash_profile

export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
export JAVA_10_HOME=/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home

export GRADLE_HOME=${HOME}/Library/gradle/gradle-4.10.2
exprot GRADLE_USER_HOME=${HOME}/workstation/gradle/.gradle



alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk10="export JAVA_HOME=$JAVA_10_HOME"

export JAVA_HOME=$JAVA_8_HOME

PATH="${PATH}:${JAVA_HOME}:${GRADLE_HOME}/bin"
export PATH

2.

在库目录下,创建init.gradle文件,编辑以下内容,并执行gradle build

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
        }
    }
}  

 把项目中的build.gradle的此处修改

allprojects {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    }
}

  

原文地址:https://www.cnblogs.com/kingdelee/p/9688341.html