Create a gist now

Instantly share code, notes, and snippets.

@lhazlewood /m2
Created Mar 24, 2016

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment