Maven command to determine which settings.xml file Maven is using
You can use the maven help plugin to tell you the contents of your user and global settings files.
mvn help:effective-settings
will ask maven to spit out the combined global and user settings.
Start maven with -X option (debug) and examine the beginning of the output. There should be something like this:
...
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from c:\....\apache-maven-3.0.3\conf\settings.xml
[DEBUG] Reading user settings from c:\....\.m2\settings.xml
[DEBUG] Using local repository at C:\....\repository
...
(Original directory names are removed by me)
Your comment to cletus' (correct) answer implies that there are multiple Maven settings files involved.
Maven always uses either one or two settings files. The global settings defined in (${M2_HOME}/conf/settings.xml
) is always required. The user settings file (defined in ${user.home}/.m2/settings.xml
) is optional. Any settings defined in the user settings take precedence over the corresponding global settings.
You can override the location of the global and user settings from the command line, the following example will set the global settings to c:\global\settings.xml and the user settings to c:\user\settings.xml:
mvn install --settings c:\user\settings.xml
--global-settings c:\global\settings.xml
Currently there is no property or means to establish what user and global settings files were used from with Maven. To access these values, you would have to modify MavenCli and/or DefaultMavenSettingsBuilder to inject the file locations into the resolved Settings object.
This is the configuration file for Maven. It can be specified at two levels:
User Level. This settings.xml file provides configuration for a single user, and is normally provided in ${user.home}/.m2/settings.xml.
NOTE: This location can be overridden with the CLI option: -s /path/to/user/settings.xml
Global Level. This settings.xml file provides configuration for all Maven users on a machine (assuming they're all using the same Maven installation). It's normally provided in ${maven.home}/conf/settings.xml.
NOTE: This location can be overridden with the CLI option: -gs /path/to/global/settings.xml