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?
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
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With