Maven3 and -Dorg.apache.maven.user-settings

Thursday, 26 December 2013, 15:51

Tags: Maven

  • In Maven2 it was possible to set the location of the user settings file with the org.apache.maven.user-settings environment variable. In the same way the location of the global settings file could be set with org.apache.maven.global-settings environment variable.
  • With Maven3 this is not possible anymore. You can change the location by using the -s or -gs options when executing Maven as shown in the code snippet below.

The disadvantage is that the -s and -gs options can't be added to the MAVEN_OPTS environment variable. Prior to Maven3 it was possible to define the location of the settings file in the environment variables and add them to MAVEN_OPTS. This way you could redefine the location of the settings files in one central location.

I'm used to having a maven installation for each project and put all the settings for the project in the global settings file of the maven installation. The location of the user settings is changed to the location of the global settings via MAVEN_OPTS, so that only one settings file is used. This way all the project settings are confined in the projects directory. Now, without being able to set the location with MAVEN_OPTS, I just have to watch out to not override a setting in the user settings file. Actually I just do not have a user settings file to prevent this problem.

An interesting blog post concerning this topic can be found here. There also is a feature request for this functionality on Mavens Jira.