Last active
May 25, 2021 14:15
-
-
Save jangalinski/294f869ec307d754c5f99c044a17823e to your computer and use it in GitHub Desktop.
choose either the mvnw or the global installation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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