-
-
Save Fleshgrinder/4dea4a703e850fed44b6a6fe47876237 to your computer and use it in GitHub Desktop.
Script to execute Maven wrapper with jEnv and fallback to global Maven 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
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
JAVA_HOME=$(jenv javahome) | |
export JAVA_HOME | |
if [[ -f mvnw ]]; then | |
exec ./mvnw "$@" | |
else | |
readonly project_dir=$PWD | |
while [[ ! -f mvnw && "$PWD" != / ]]; do | |
cd .. || break | |
done | |
if [[ -f mvnw ]]; then | |
exec ./mvnw --projects "$(realpath --relative-to="$PWD" "$project_dir")" "$@" | |
else | |
cd "$project_dir" | |
exec /usr/local/bin/mvn "$@" | |
fi | |
fi |
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
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
mkdir -p ~/bin | |
curl -Lo ~/bin/mvn 'https://gist.githubusercontent.com/Fleshgrinder/4dea4a703e850fed44b6a6fe47876237/raw/mvn' | |
chmod +x ~/bin/mvn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment