Skip to content

Instantly share code, notes, and snippets.

@amgohan
Created May 4, 2017 03:14
Show Gist options
  • Save amgohan/fc0428071985cfbcf6b2988e9c9a9143 to your computer and use it in GitHub Desktop.
Save amgohan/fc0428071985cfbcf6b2988e9c9a9143 to your computer and use it in GitHub Desktop.
switch maven settings.xml by profile (home, work) for example
#!/bin/bash
set -e
PROFILE=$1
SETTINGS_FILE=~/.m2/settings.xml.${PROFILE}
if [ -a ${SETTINGS_FILE} ]
then
cp -f ~/.m2/settings.xml.${PROFILE} ~/.m2/settings.xml
echo "Profile [$1] activated [~/.m2/settings.xml]"
else
echo "File not found [${SETTINGS_FILE}]"
fi
@amgohan
Copy link
Author

amgohan commented May 4, 2017

How to install

sudo wget https://gist.githubusercontent.com/amgohan/fc0428071985cfbcf6b2988e9c9a9143/raw/6aec9ef30aff1df57cbbd3885167c08e83f6a46e/mvnprofile -O /bin/mvnprofile && sudo chmod +x /bin/mvnprofile

How to use

suppose you have 2 settings.xml one for your work and the other for your own projects at home ~/.m2/settings.xml.home and ~/.m2/settings.xml.work
you can switch between them by using

# to switch to home settings.xml
mvnprofile home

# switch to work settings.xml
mvnprofile work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment