Skip to content

Instantly share code, notes, and snippets.

@Fleshgrinder
Last active Mar 18, 2020
Embed
What would you like to do?
Script to execute Maven wrapper with jEnv and fallback to global Maven installation.
#!/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
#!/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