Skip to content

Instantly share code, notes, and snippets.

@lhazlewood
Created March 24, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lhazlewood/0ffbbb6d3d043c147710 to your computer and use it in GitHub Desktop.
Save lhazlewood/0ffbbb6d3d043c147710 to your computer and use it in GitHub Desktop.
Bash script to switch maven configurations by name
#!/usr/bin/env bash
LINK_FILE="$HOME/.m2/settings.xml"
if [ ! -L "$LINK_FILE" ]; then
echo "This program expects $LINK_FILE to be a symbolic link."
exit 1
fi
if [ -z "$1" ]; then
ls -lah "$LINK_FILE"
#out=$(ls -alh "$LINK_FILE")
#echo "$out"
exit 0
fi
TARGET_FILE="$HOME/.m2/$1.settings.xml"
if [ ! -f "$TARGET_FILE" ]; then
echo "$TARGET_FILE does not exist."
exit 1
fi
ln -sf "$TARGET_FILE" "$LINK_FILE"
ls -lah "$LINK_FILE"
@steve-taylor
Copy link

steve-taylor commented Jun 2, 2018

Nice work, @lhazlewood. I wanted something to swap out the entire ~/.m2 directory, not just settings.xml, so I created Maven Environment Manager.

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