Thursday, October 18, 2012

Automatically switch your mvn settings

I have one primary development notebook and take that with me wherever I go. Now in a company setting you usually have proxies and whatnot. And I think it's an official best practice to roll your own company or departement maven proxy/cache.

So dependent on where you are, you might need a different maven ~/.m2/settings.xml file. Here's a very simple shell function you can add to your ~/.bashrc

Loading ....

This just checks for the ip of eth0 and calls mvn with a special settings.xml. In all other cases mvn is run with the vanilla config (or none, since the settings.xml is optional).

Of course you can extend on this to check for something else, basically anything is possible.

Simple yet effective.

No comments:

Post a Comment