Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Maven Mirrors for the same repositories

As a consultant, I have multiple clients that I'm doing work for. Each client utilizes their own internal Maven repository that is also set up to mirror Central and other external repositories. I need to configure my maven installation on my laptop so that when I'm doing work for one client, it utilizes their internal repository for everything.

I had thought I would be able to utilize profiles to handle this, but mirror settings cannot be changed per-profile.

Does anybody have suggestions on how to approach this maven configuration?

Note: A similar question is here: How do I configure maven to access maven central if nexus server is down?, but that question deals with switching between Central coming from a mirror or not. What I need is for Central (and others) to come from one mirror or a different one based on some property/setting/variable etc.

like image 211
MBru Avatar asked Jun 25 '12 23:06

MBru


1 Answers

Create two shell aliases:

alias build_at_home="mvn -s $HOME/.m2/home_settings.xml"
alias build_at_work="mvn -s $HOME/.m2/work_settings.xml"

The "-s" option is handy for explicitly stating which environment settings file to use. We use this mechanism on our shared build server to ensure each project build is isolated.

Obviously on windows you could create a set of batch files.

like image 166
Mark O'Connor Avatar answered Oct 11 '22 11:10

Mark O'Connor