gradle全局配置

gradle全局配置:

gradle user home目录结构:

gradle全局配置

  1. 指定本地仓库方式:

    1 通过设置环境变量 GRADLE_USER_HOME
    2 在gradle.properties中配置
    gradle.user.home=<本地仓库地址>

这部分没有在官方找到具体的说明,是参考网上其他资料,是否生效存疑

默认本地仓库地址:
$USER_HOME/.gradle/caches/modules-2/files-2.1

  1. 配置私服地址

$USER_HOME/.gradle/init.d文件夹下创建init.gradle文件

init.gradle

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
        }
    }
}
  1. 其他全局配置

gradle.properties

org.gradle.caching=(true,false)
When set to true, Gradle will reuse task outputs from any previous build, when possible, resulting is much faster builds. Learn more about using the build cache.

org.gradle.caching.debug=(true,false)
When set to true, individual input property hashes and the build cache key for each task are logged on the console. Learn more about task output caching.

org.gradle.configureondemand=(true,false)

gradle.properties详细可配置参数:

参考资料

gradle 用户指南
Gradle的配置

上一篇:A Child's History of England.121


下一篇:A Child's History of England.115