allprojects{repositories {def REPOSITORY_URL = ''all { ArtifactRepository repo ->if(repo instanceof MavenArtifactRepository){def url = repo.url.toString()if (uallprojects{
repositories {
def REPOSITORY_URL = 'http://localhost:8181/nexus/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/') || url.startsWith('https://maven.google.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven {
url REPOSITORY_URL
}
jcenter() {
url REPOSITORY_URL
}
}
}
将上述代码放在init.gradle中,并放在.gradle目录下。