// Modify from https://doc.nju.edu.cn/books/e1654/page/maven allprojects { buildscript { repositories { def ALIYUN_PUBLIC_URL = 'https://maven.aliyun.com/repository/public/' def ALIYUN_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin/' all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_PUBLIC_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/') || url.contains('plugins.gradle.org/m2')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } } } maven { url ALIYUN_PUBLIC_URL } maven { url ALIYUN_PLUGIN_URL} mavenLocal() } } repositories { def ALIYUN_PUBLIC_URL = 'https://maven.aliyun.com/repository/public/' def ALIYUN_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin/' all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_PUBLIC_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/') || url.contains('plugins.gradle.org/m2')) { project.logger.lifecycle "Repository ${repo.url} deleted." remove repo } } } maven { url ALIYUN_PUBLIC_URL } maven { url ALIYUN_PLUGIN_URL } mavenLocal() } }