gradle全局配置:
gradle user home目录结构:
gradle project home 目录结构
build项目构建后生成目录,类似于target;
build.gradle:类似于 Maven POM.xml
settings.gradle 项目的配置
gradle.properties: 项目全局变量配置
-
指定本地仓库方式:
1 通过设置环境变量 GRADLE_USER_HOME
2 在gradle.properties中配置
gradle.user.home=<本地仓库地址>
这点是和maven的整体机构很大的不同,maven中支持主目录与本地仓库分离,但是gradle是将主目录和仓库放在一起.所以gradle.user.home指定的就是你gradle的用户主目录
默认本地仓库地址:
$USER_HOME/.gradle/caches/modules-2/files-2.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
}
}
}
- 其他全局配置
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)