Gradle Modifying the Maven warehouse address

Source: Internet
Author: User
Tags jcenter

Recently migrating some projects to Android Studio, using the Gradle build is really a lot easier than the original ant. However, it is really painful to download the dependent speed at compile time.

If you can switch to a domestic MAVEN image warehouse, such as open source China's Maven library, or replace it with a self-built MAVEN, it must be excellent.

An easy way to modify the Build.gradle in the project root directory is to replace it with the following jcenter() mavenCentral() :

allprojects {    repositories {        'http://maven.oschina.net/content/groups/public/ ' }    }}

But Jiabuzhu project more, difficult not to change each?

Naturally there is a convenient way, the following copy to the name of the init.gradle file, and save to the USER_HOME/.gradle/ folder.

allprojects{repositories {def repository_url='Http://maven.oschina.net/content/groups/public'All {artifactrepository repo-if(Repo instanceof mavenartifactrepository) {def URL=repo.url.toString ()if(Url.startswith ('Https://repo1.maven.org/maven2') || Url.startswith ('https://jcenter.bintray.com/') ) {project.logger.lifecycle"Repository ${repo.url} replaced by $REPOSITORY _url."remove Repo}} } maven {URL repository_url} }}

init.gradleThe file is actually Gradle 初始化脚本 (initialization Scripts) and is the global configuration of the runtime.

Gradle Modifying the Maven warehouse address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.