Shan
Shan

Reputation: 531

Maven ignores settings.xml file

I have added proxy configuration in settigns.xml file, but it is not used by Maven, i confirmed this by making the settings.xml file invalid. I ran the maven install command to update settings and global-settings to point to the correct file, still no luck. I am using maven3.0.4.

Upvotes: 15

Views: 69372

Answers (11)

ymssa___
ymssa___

Reputation: 1073

Right click on the project root if you are using IntelliJ IDEA. Go to Maven -> Create 'setting.xml' file. Do your configuration there.

Upvotes: 0

Ithar
Ithar

Reputation: 5445

What I found was that even if I set my own maven setting file using the --settings or -s command such as:

mvn -s $MAVEN_HOME/libexec/conf/my-settings.xml clean

Maven was still reading the default global setting.xml

Two ways that one can slove this:

  1. Rename the setting.xml to something like setting.xml.bak in the $MAVEN_HOME/conf dicrectory.
  2. The preferred approach add global to the command -gs hence the final command becomes:

mvn -gs $MAVEN_HOME/libexec/conf/my-settings.xml clean

Upvotes: 2

Pumuckline
Pumuckline

Reputation: 637

It's almost to stupid to tell, but it might save some time for somebody else: If you're using a new computer, make sure file extensions are displayed. Otherwise your "settings.xml" file probably is a "settings.xml.txt" file in fact...

Upvotes: 11

user2459012
user2459012

Reputation: 23

I have also been facing the same issue. I removed the file and folder, but still maven was still picking the settings.

For me, restarting the system solved the issue.

Upvotes: 0

Deepansh Singh
Deepansh Singh

Reputation: 158

You can set the path of settings file in Eclipse* as :

  1. In the menubar goto Window -> Preferences

  2. In Preferences Dialog, Goto Maven Section(On the left) and Expand it.

  3. Click on UserSettings.

  4. Add the path of settings file using Browse. The default for most users will be (C:\Users\.m2\settings.xml). It will be shown in grey but you need to actually enter the location.

  5. Click on Update Settings !

You can also enable debug logs and stack traces for debugging by clicking on the Maven Section in the Preferences dialog and Checking the box against the label "Debug Output".

  • P.S. I am currently using Eclipse(Neon) on Windows 10 x64.

Upvotes: 0

ravi.zombie
ravi.zombie

Reputation: 1570

have you tried with these options: from the command line to specify the settings file?

mvn -o –Dmaven.repo.local=$HOME/.my_m2path/repository clean install --settings $HOME/.my_m2path/settings.xml  Dcheckstyle.skip=true –DskipTests

Some options that might not be necessary

  1. -o is for offline (unless you have all your repos in your m2, its suggested to skip this option)
  2. skip tests is for skipping tests while building
  3. –Dmaven.repo.local - repo path - if you are having own repo path, then use this option
  4. --settings $HOME/.my_m2path/settings.xml (remember there is space between settings and the path)

Upvotes: 4

jiming
jiming

Reputation: 101

Please make sure you are using the settings.xml which you modified. for example: your using IDE's embedded maven which using different settings.xml in you operation system.

Upvotes: 0

Cedric Reichenbach
Cedric Reichenbach

Reputation: 9319

For those using Linux

In the Ubuntu package repository (and probably other disto's too), there are two maven packages: maven and maven2. For some reason, I had maven2 installed, which seems to ignore settings.xml in ~/.m2.

As a solution, I removed it using

sudo apt-get purge maven2

and installed the other one with

sudo apt-get install maven

What's going on?

I couldn't find a reliable source, but apparently, maven2 is an older version (2.x), as the latest maven has version 3.x and is served with maven.

Upvotes: 2

Deltharis
Deltharis

Reputation: 2373

Since there is no accepted answer, and I encountered that problem today and other answers proved unhlepful as the file path was correct:

The solution is to restart your computer. No, seriously. After restart maven is guaranteed to read settings.xml file again and use whatever changes you made.

Upvotes: 1

nwinkler
nwinkler

Reputation: 54457

Try running Maven with the -X option. It should print as part of the debug output which settings file is being used.

Since you already tried it with an invalid file, I bet that something is wrong with the location of your file.

Upvotes: 24

j13r
j13r

Reputation: 2671

Make sure it is in the right directory (HOME/.m2/settings.xml)

You can find the relevant paths and a proxy example here: Maven proxy settings not working

And of course the reference is always useful: https://maven.apache.org/settings.html

Upvotes: 5

Related Questions