Skip to content

Instantly share code, notes, and snippets.

@yangl
Created September 1, 2023 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yangl/8dc81b385c8182efdc577bf9d45e4058 to your computer and use it in GitHub Desktop.
Save yangl/8dc81b385c8182efdc577bf9d45e4058 to your computer and use it in GitHub Desktop.
init.gradle
allprojects {
repositories {
maven {
allowInsecureProtocol = true
url = 'https://maven.aliyun.com/repository/public'
}
def REPOSITORY_URL = 'https://maven.aliyun.com/repository/public/'
//做一些国外不稳定的地址连接的替换
all {
ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith('https://artifacts.elastic.co/maven')
|| url.startsWith('https://repo1.maven.org/maven2')
|| url.startsWith('https://repo.maven.org/maven2')
|| url.startsWith('https://jcenter.bintray.com/')
|| url.startsWith('https://repo.maven.apache.org/maven2')
) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment