Android开发:《Gradle Recipes for Android》阅读笔记1.7——仓库配置

repositories块告诉gradle哪里去寻找依赖,默认的android studio使用jcenter或者mavenCentral。jcenter仓库位于https://jcenter.bintray.com(注意连接是ttps请求)

maven仓库有两种方式,mavenCentral代表着http://repo1.maven.org/maven2/上面的仓库;mavenLocal代表本地的maven缓存。

任何maven仓库都可以使用url添加到默认的仓库列表中,如

repositories {
    maven {
        url 'http://repo.spring.io/milestone'
    }
}

密码保护的仓库可以使用credentials块,如

repositories {
    maven {
        credentials {
            username 'username'
            password 'password'
        }
        url 'http://repo.mycompany.com/maven2'
    }
}

IVY和本地仓库也可以用相似的语法添加,如

repositories {
    ivy {
        url 'http://my.ivy.repo'
    }
}

repositories {
    flatDir {
       dirs 'lib' 
    }
}

当在配置中设置多个仓库地址,gradle会从上至下逐个访问,直到解决所有依赖。

原文地址:https://www.cnblogs.com/tootwo2/p/6360408.html