Say I have Sonatype Nexus running on an internal server, and I would like to use it to proxy repo1.maven.org and other repositories. In Maven I would simply add a <mirror>
configuration to settings.xml
. How can I do this with Gradle?
Update: I would like to do this without having to hard-code the URL of my Nexus instance into each and every project I have. So I'm looking for an exact replica of the Maven <mirror>
setting.
The best I could come up with for now is to do something like this:
repositories {
maven {
url "$nexusUrl/content/groups/public"
}
}
And then have this in ~/.gradle/gradle.properties
on each developer's computer:
nexusUrl = https://nexus.company.com
However, this looks hacked, and I still have to add the 5 lines to each project. Is there a more elegant way to do this?
Init scripts might be the best way to go. Take a look at this chapter in the User Guide.
They provide a way for you to inject logic into all of your projects.
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