Created
April 2, 2020 09:52
-
-
Save aztack/2edc92a8a3ed767cdd46f4a07a1b644e to your computer and use it in GitHub Desktop.
init.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ~/.gradle/init.gradle | |
allprojects { | |
def google_uri = new URI('https://maven.aliyun.com/repository/google') | |
def central_uri = new URI('https://maven.aliyun.com/repository/central') | |
def jcenter_uri = new URI('https://maven.aliyun.com/repository/jcenter') | |
repositories { | |
all { | |
ArtifactRepository repo -> | |
if (repo instanceof MavenArtifactRepository) { | |
def url = repo.url.toString() | |
if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo1.maven.org/maven2')) { | |
project.logger.lifecycle "Repository ${repo.url} replaced by ${central_uri}." | |
repo.setUrl(central_uri) | |
} else if (url.startsWith('https://jcenter.bintray.com/')) { | |
project.logger.lifecycle "Repository ${repo.url} replaced by ${jcenter_uri}." | |
repo.setUrl(jcenter_uri) | |
} else if (url.startsWith('https://dl.google.com/dl/android/maven2')) { | |
project.logger.lifecycle "Repository ${repo.url} replaced by ${google_uri}." | |
repo.setUrl(google_uri) | |
} | |
} | |
} | |
} | |
buildscript { | |
repositories { | |
maven { url 'https://maven.aliyun.com/repository/public/' } | |
all { ArtifactRepository repo -> | |
if (repo instanceof MavenArtifactRepository) { | |
def url = repo.url.toString() | |
if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo1.maven.org/maven2')) { | |
project.logger.lifecycle "Repository ${repo.url} replaced by ${central_uri}." | |
repo.setUrl(central_uri) | |
} else if (url.startsWith('https://jcenter.bintray.com/')) { | |
project.logger.lifecycle "Repository ${repo.url} replaced by ${jcenter_uri}." | |
repo.setUrl(jcenter_uri) | |
} else if (url.startsWith('https://dl.google.com/dl/android/maven2')) { | |
project.logger.lifecycle "Repository ${repo.url} replaced by ${google_uri}." | |
repo.setUrl(google_uri) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment