Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy all maven dependency repositories through internal Nexus

I have a project with lot of dependencies into a lot of remote repositories and even those dependencies sometimes require other remote repositories.

I want to create a stable build environment and I want my local Nexus installation to proxy all requirements of the project so I can reproduce the builds without going to the internet after I set everything up once.

I.e., my .m2/settings.xml would contain:

<mirrors>
    <mirror>
        <id>my.public</id>
        <url>http://localhost:8081/nexus/content/groups/public</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

But of course this is not enough. Nexus will not arbitrary proxy each and every request it gets from my maven installation.

Currently as I understand it and this is how I got it working, for every remote repository I encounter, I create a proxy in Nexus and add it to the public group.

In my case these are like 15 or 20 remote repositories. Most of them are further dependency of my packages, i.e. not obvious that I need them until I run a maven build and hit them. I found them to be mostly referenced in parent POMs so far.

My question: is there a way to configure Nexus somehow so I do not need to have to add every repository by hand?

When I re-read my question, it almost sounds I want a real HTTP proxy but what's the point of Nexus then? Of course this is a rhetoric question, but how do I solve this issue without adding all of them manually?

All I found in the Nexus documentation is http://www.sonatype.com/books/nexus-book/reference/config-sect-custom.html:

... you might encounter projects which are unable to retrieve artifacts from your local Nexus installation

and

... add this repository to Nexus as a new proxy repository and then add the new proxy repository to the public group

like image 230
mark Avatar asked Nov 14 '11 08:11

mark


1 Answers

Not that I'm aware of. We currently have 30-40 repositories mirrored through our Nexus installation for just this reason. We use a similar mirror statement in settings.xml to force everyone to use our repo as a one stop shop. We do however enforce (through policy) that developers do not add repositories to pom files in projects. Instead, they submit a request to have a proxy added.

like image 82
Michael Avatar answered Sep 24 '22 22:09

Michael