阿里云gradle镜像库配置

本文介绍如何通过配置阿里云Gradle仓库来加速Maven项目的构建过程,解决因远程仓库下载速度慢而造成的等待时间过长问题。

经常使用maven远程仓库里jar包的同学,最头疼的事情莫过于加了jar包依赖配置之后,需要漫长的下jar包的过程,因为maven仓库网站是国外网站,速度非常的慢。在国内下好jar包放到本地再加载又过于麻烦

gradle配置:将原来的google(),jcenter()直接替换掉或者放到这个的前面(默认是从上往下寻找,所以要放到google()、jcenter()的前面,如果加在google()、jcenter()后面,等同于没加.


buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
    	// 以下四行代码为阿里gradle 源
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
    	// 所有的model 都优先使用阿里源
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值