0

I have a local-settings.xml in my project base directory inside the .mvn folder . When I do clean install , maven is not refering to this file. How can I refer to this file without the -s option.

My directory structure is exactly like in this question : Create project-specific Maven settings

  • did you set `M2_HOME` ? – vikingsteve May 22 '18 at 09:23
  • Yes.. When i do mvn -s install it is working fine. But when i do mvn clean install i'm getting error in downloading jar i mentioned in my local-settings.xml – Ruckmani Ravichandran May 22 '18 at 09:26
  • 1
    You simply can't refer a settings.xml file in `.mvn` cause the settings.xml should be located in `$HOME/.m2/` or you have to give it explicitly via command line `-s ..` furthermore settings `M2_HOME` does not help...furthermore is deprecated... – khmarbaise May 22 '18 at 09:39
  • But i want to share this settings.xml file to the team. So is there a way to execute the settings.xml while we do mvn clean install instead of mvn -s ? – Ruckmani Ravichandran May 22 '18 at 10:19
  • I have resolved the issue by creating a maven.config file in the base directory of the project added these lines to point my settings.xml and settings-security.xml when I do "mvn clean install". --settings ./.mvn/settings.xml -Dsettings.security=./.mvn/settings-security.xml – Ruckmani Ravichandran May 23 '18 at 04:31

1 Answers1

1

You have to check what settings are maven taking during the deployment of the artifacts by using this command:

mvn help:effective-settings

Sometimes it can happen that you are using local settings and global settings (taking first the provided by the maven installation and then the provided by the repository), but maven is not recognizing both. With this command, you can verify the actual settings maven is taking during the deployment. In addition, you can locate the actual file maven is taking and, as a consequence, modify the file properly (with vim, for example) according to the configuration needed by the server.

Remember that there are two locations where a settings.xml file may live:

  1. Maven installation directory

    $M2_HOME/conf/settings.xml

  2. User-specific settings file

    ~/.m2/settings.xml

If both files exists, their contents gets merged, with the user-specific settings.xml being dominant. https://maven.apache.org/settings.html