Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Sonatype Nexus with Gradle to proxy repsitories?

Tags:

gradle

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?

like image 417
Lóránt Pintér Avatar asked Nov 03 '12 14:11

Lóránt Pintér


1 Answers

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.

like image 79
ajoberstar Avatar answered Sep 22 '22 06:09

ajoberstar