The easiest way to apply this change for all projects is to use the gradle init script, which forces you to use the oschina repository instead of mavenCentral. you can put this:
allprojects{ repositories { all { ArtifactRepository repo -> println repo.url.toString() if ((repo instanceof MavenArtifactRepository) && repo.url.toString().startsWith("https://repo1.maven.org/maven2")) { project.logger.warn "Repository ${repo.url} removed. Only $coporateRepoUrl is allowed" remove repo } } maven { url "http://maven.oschina.net/content/groups/public" } } }
to the gradle initialization file. Now you can use this by calling "gradle build -I yourInitFile.gradle", or you put this logic in the init.gradle file stored in your gradle home directory in the USER_HOME/.gradle/ . Now this will be called by every gradle call without explicitly setting -I
Another option is to create a custom gradle distribution where this file is stored in the init.d directory of the distribution.
source share