Skip to content

Instantly share code, notes, and snippets.

@jangalinski
Last active May 25, 2021 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jangalinski/294f869ec307d754c5f99c044a17823e to your computer and use it in GitHub Desktop.
Save jangalinski/294f869ec307d754c5f99c044a17823e to your computer and use it in GitHub Desktop.
choose either the mvnw or the global installation
# dynamically choose mvnw or global.
function mvn() {
# Stop the search on this folder.
# "/" is the highest possible, but you can go for $HOME for example
STOP="/"
# Location of Maven.
# $MVN_HOME/bin/mvn is an option...
MVN_CMD="/usr/local/bin/mvn"
# ----------------------------------------------------------------------------
# Don't edit below this line
#
DIR="$( pwd )"
FILE="null"
while [ $DIR != $STOP ]
do
if [ -e $DIR/mvnw ]
then
FILE="$DIR/mvnw"
break
else
DIR="$( dirname "$DIR" )"
fi
done
if [ $FILE != "null" ]
then
CMD=$FILE
else
CMD=$MVN_CMD
fi
# execute maven command with args
echo "Calling $CMD $@"
$CMD $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment