While working with Gradle in my country, download jars from maven central is a very timely-costed work.
I wanna change the mavenCentral to maven-nexus:
which means whenever I use mavenCentral it always points to oschina
------edit------
I have lots of projects with mavenCentral, so I do not want change each file.
Now in new scripts I use maven{ url ...} Any easy way??
Any one can hlep?
Thanks!
The easiest way to apply this change for all projects is to use an gradle init script that forces the use of 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"
}
}
}
into an gradle init file.
Now you can use this by calling "gradle build -I yourInitFile.gradle" or you put this logic into a init.gradle
file stored in your gradle home directory in USER_HOME/.gradle/
directory. Now this will be picked up by every gradle invocation without explicitly setting -I
Another option is to create a custom gradle distribution where this file is store in the init.d directory of the distribution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With