maven command line how to point to a specific settings.xml for a single command?

MavenCommand LineOverridingSettingsOptional Parameters

Maven Problem Overview


Is it possible to point to a specific settings file in order to override the default settings.xml being used by maven for a single command? Example:

mvn clean install -Dparam # -> pass specific settings file path as param to override default "home/.m2/settings.xml"

Maven Solutions


Solution 1 - Maven

You can simply use:

mvn --settings YourOwnSettings.xml clean install

or

mvn -s YourOwnSettings.xml clean install

Solution 2 - Maven

I just find it very difficult, It was still not working for me. Then I checked the comments and understood that you have to override global settings. Pointed by @khmarbaise I am adding this in a new answer.

mvn -gs /local-path/settings.xml clean install

mvn --global-settings /local-path/settings.xml clean install

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionguilheblView Question on Stackoverflow
Solution 1 - MavenkhmarbaiseView Answer on Stackoverflow
Solution 2 - MavenAakarsh GuptaView Answer on Stackoverflow