Advertisement
Advertisement


Maven command to determine which settings.xml file Maven is using


Question

How do I use maven command line to determine which settings.xml file Maven is picking up?

2018/10/04
1
285
10/4/2018 12:04:13 PM

Accepted Answer

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)

2012/05/10
338
5/10/2012 7:18:31 AM


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.

2012/11/09

This is the configuration file for Maven. It can be specified at two levels:

  1. 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
    
  2. 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
    
2009/08/11

Quick and dirty method to determine if Maven is using desired settings.xml would be invalidate its xml and run some safe maven command that requires settings.xml.

If it reads this settings.xml then Maven reports an error: "Error reading settings.xml..."

2009/09/17

The M2_HOME environment variable for the global one. See Settings Reference:

The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information. There are two locations where a settings.xml file may live:

  • The Maven install: $M2_HOME/conf/settings.xml
  • A user's install: ${user.home}/.m2/settings.xml
2009/08/11

Source: https://stackoverflow.com/questions/1261215
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]