diff --git a/bin/gng b/bin/gng index a772416..4fa30a5 100755 --- a/bin/gng +++ b/bin/gng @@ -140,6 +140,20 @@ bootstrap_help() { printf '\t%s\n' "-h, --help: Prints help" } +function parse_gradle_version() { + if command -v python &> /dev/null + then + python -c "import json,sys; obj=json.load(sys.stdin); print obj['version'];" + return + fi + if command -v python3 &> /dev/null + then + python3 -c "import json,sys; obj=json.load(sys.stdin); print (obj['version']);" + return + fi + die "Cannot find python/python3 interpreter !" +} + function bootstrap() { local _arg_version _arg_distribution_type _arg_destination_dir _arg_version="latest" @@ -182,7 +196,7 @@ function bootstrap() { if [[ "${_arg_version}" == "latest" ]]; then info "Fetching the latest Gradle version from services.gradle.org" _arg_version=$(curl -m 60 -sSL "https://services.gradle.org/versions/current" | - python -c "import json,sys;obj=json.load(sys.stdin);print obj['version'];") || die "Failed to fetch the version info!" + parse_gradle_version) || die "Failed to fetch the version info!" info "The latest Gradle version is ${_arg_version}" fi __install_gw "${_arg_version}" "${_arg_distribution_type}" "${_arg_mirror:-}" "${_arg_destination_dir}"