Windows使用脚本自动化配置环境 入门篇(自动配置镜像

前言

只包含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

发布了21 篇原创文章 · 获赞 2 · 访问量 5181
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 深蓝海洋 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览