Thursday, 19 September 2013

Maven settings.xml - global and user-specific

Sometimes you have to amend the Maven `settings.xml` file to add a proxy or various repositories.

I had to do that a couple of days ago when experimenting with a 3rd party library.

What I sometimes forget, is that there are two `settings.xml` files. Now I shouldn't forget this, because it is quite clear on the Maven Apache site. http://maven.apache.org/settings.html

But I do.

The settings.xml file in

  • `%M2_HOME%/conf/settings.xml` is the global settings.
  • your `.m2` user directory is your user-specific settings.
    • This file doesn't exist until you create it, which might explain why I forget about it.

Duplicate settings in the user-specific file, override the settings in the global settings.

I was reminded of this because of the permission schemes in Windows 7 which wouldn't let me save my global settings without upping my permissions to admin.

You can see the combined settings if you issue the command:

mvn help:effective-settings

Some useful references:

No comments:

Post a Comment