前言
只包含Windows端配置
需要Git的Bash环境
gradle 镜像脚本
#!/bin/bash
# Create C:\Users\Administrator\.gradle
dirPath="$HOMEPATH\.gradle"
if [ ! -d "$dirPath" ];then
mkdir "$dirPath"
fi
# Create init file
fileName="$dirPath\init.gradle"
cat << 'CONTENT' > $fileName
allprojects{
repositories {
def ALIYUN_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')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_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 ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
}
}
}
CONTENT
printf "Copy complete \nPrees any key to quit"
read
参考
<< EOF基本使用
https://blog.csdn.net/zongshi1992/article/details/71693045
https://www.cnblogs.com/archoncap/p/6080088.html
EOF变量自动解析问题
https://blog.csdn.net/whatday/article/details/98579404