阿里云gradle镜像库配置

经常使用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
}

猜你喜欢

转载自blog.csdn.net/Marvinhq/article/details/83016164