在天朝使用jcenter、mavenCentral及google三个远程仓库,Gradle Sync会很慢,google仓库甚至需要科学上网才能访问。为了加快Gradle Sync速度,一招教你优先用 阿里云仓库服务 的仓库作为下载源。
一劳永逸之道
将本项目的gradle/init.d/init.gradle复制到USER_HOME/.gradle/下即可。
USER_HOME在Windows上大约为C:/Users/liyujiang/.gradle/,在Linux上大约为/home/liyujiang/.gradle/。
init.d/init.gradle内容为:
/*
*
* The software is licensed under the Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v2 for more details.
*/
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/repositories/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
}
}
allprojects {
repositories {
maven { url 'https://repo.eclipse.org/content/repositories/paho-releases/' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/repositories/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url "https://www.jitpack.io" }
}
}