Gradle配置
编辑
2204
2024-05-07
配置本地仓库地址
Gradle默认存放jar路径:C:\Users\Administrator\.gradle\caches\
在环境变量中添加名为 GRADLE_USER_HOME
,值为本地仓库位置的环境变量即可
全局配置 Gradle
全局配置gradle依赖及插件仓库之后就不需要每个项目来一次国内仓库替换了。
直接在.gradle
文件夹下添加文件init.gradle
/ init.gradle.kt
for kotlin dsl.
如果同时存在init.gradle
和init.gradle.kt
,则优先按照init.gradle
中的配置
除非手动指定初始化脚本--init-script
init.gradle
allprojects {
buildscript{
repositories {
maven { name 'aliyunCentral' ; url 'https://maven.aliyun.com/repository/central' }
maven { name 'aliyunJcenter' ; url 'https://maven.aliyun.com/repository/jcenter' }
maven { name 'aliyunGoogle' ; url 'https://maven.aliyun.com/repository/google' }
maven { name 'aliyunPlugin' ; url 'https://maven.aliyun.com/repository/gradle-plugin' }
mavenCentral()
mavenLocal()
google()
}
}
repositories {
maven { name 'aliyunCentral' ; url 'https://maven.aliyun.com/repository/central' }
maven { name 'aliyunJcenter' ; url 'https://maven.aliyun.com/repository/jcenter' }
maven { name 'aliyunGoogle' ; url 'https://maven.aliyun.com/repository/google' }
maven { name 'aliyunPlugin' ; url 'https://maven.aliyun.com/repository/gradle-plugin' }
google()
mavenLocal()
}
}
init.gradle.kt
allprojects {
buildscript {
repositories {
maven("https://maven.aliyun.com/repository/public")
maven("https://maven.aliyun.com/repository/central")
maven("https://maven.aliyun.com/repository/jcenter")
maven("https://maven.aliyun.com/repository/gradle-plugin")
mavenCentral()
mavenLocal()
google()
}
}
repositories {
maven("https://maven.aliyun.com/repository/public")
maven("https://maven.aliyun.com/repository/central")
maven("https://maven.aliyun.com/repository/jcenter")
maven("https://maven.aliyun.com/repository/gradle-plugin")
google()
mavenLocal()
}
}
- 172
-
分享