Skip to content

Commit

Permalink
Add support for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
yantonov committed Jun 7, 2021
1 parent 72970c4 commit af86cbe
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bin/gng
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit af86cbe

Please # to comment.