Last active
August 30, 2020 18:33
-
-
Save Fleshgrinder/b4411e49fb97f000d57b65755d49740c to your computer and use it in GitHub Desktop.
Global script to resolve to the closest available Gradle Wrapper script.
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 | |
if command -v jenv &>/dev/null; then | |
JAVA_HOME=$(jenv javahome) | |
export JAVA_HOME | |
fi | |
if [[ -x gradlew ]]; then | |
exec ./gradlew "$@" | |
else | |
readonly cwd=$PWD | |
while [[ ! -x gradlew && "$PWD" != / ]]; do | |
cd .. || break | |
done | |
if [[ -x gradlew ]]; then | |
exec ./gradlew --project-dir="$cwd" "$@" | |
elif gradle=$(PATH="${GRADLE_HOME:-/opt/gradle}/bin/gradle:${SDKMAN_CANDIDATES_DIR:-}/gradle/current/bin:/usr/local/bin:/usr/bin" command -v gradle); then | |
cd "$cwd" | |
exec "$gradle" "$@" | |
else | |
echo 'Could not find gradle in your PATH, make sure it is available.' >&2 | |
exit 1 | |
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/gradle 'https://gist.githubusercontent.com/Fleshgrinder/b4411e49fb97f000d57b65755d49740c/raw/gradle' | |
chmod +x ~/bin/gradle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment