Koray Tugay
Koray Tugay

Reputation: 23844

How can I tell maven to use specific settings.xml on project bases?

So my project comes with settings.xml together with its pom.xml.

Is there any way in pom.xml to specify to use the settings.xml in the same folder?

Upvotes: 4

Views: 4115

Answers (2)

geoand
geoand

Reputation: 64079

It seems that Maven does not allow what you are trying to do, and moreover specifically advised against it. The following excerpt is taken from the official documentation which is Apache Maven - 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

The former settings.xml are also called global settings, the latter settings.xml are referred to as user settings. If both files exists, their contents gets merged, with the user-specific settings.xml being dominant.

Upvotes: 5

Keta
Keta

Reputation: 167

If someone is still interested, at least with Maven 3.6.3 you can specify the path to the user settings file as an argument with

-s /path/to/user/settings.xml

Likewise, the path to the global settings is specified with

-gs /path/to/global/settings.xml

Upvotes: 4

Related Questions