ubuntu16.04 安装gradle

1.安装sdk
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version
2.安装gradle
sdk install gradle 4.9
3.配置国内仓库地址
vim .gradle/init.gradle
allprojects{
    repositories {
        def 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('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
            url REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}
4.gradle代码的配置
#在项目下添加gradle.properties
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
systemProp.https.proxyUser=
systemProp.https.proxyPassword=

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.http.proxyUser=
systemProp.http.proxyPassword=

你可能感兴趣的:(ubuntu16.04 安装gradle)