Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which maven settings.xml file will sudo use?

Tags:

unix

maven

I have a shell script which runs a maven build task. When the script is run, it is run as the sudo user. However, I am behind a proxy and therefore need to specify proxy details inside my ~/.m2/settings.xml file. This is currently in the main user's home directory.

What I've found is that when this script is run as sudo, it's not picking up the settings.xml file from the other user's ~/.m2/settings.xml file.

How can I specify these settings for the sudo/root user? Should I just put this settings.xml inside the root user's home directory as well?

like image 878
jcm Avatar asked Oct 30 '14 05:10

jcm


2 Answers

When you use sudo, I think user.home property changes and that is why this,

You can explicitly specify settings file by

 -s

for example

mvn clean compile -s /home/foo/.m2/settings.xml
like image 177
jmj Avatar answered Nov 03 '22 10:11

jmj


If all users on the machine will always need the proxy settings you can simply add them to the global settings.xml file.

This can normally be found at $M2_HOME/conf/settings.xml.

like image 30
DB5 Avatar answered Nov 03 '22 10:11

DB5