Feature: Updating url and parser to fetch from Adoptium

This commit is contained in:
david 2024-05-11 20:16:48 +02:00
parent 6ee83e1056
commit d15b451319

25
warp4j
View File

@ -273,20 +273,20 @@ function choose_distro_type() {
# actually choose distro type
JAVA_DISTRO_TYPE=$(choose_distro_type)
# generates adoptopenjdk api url
# generates adoptium api url
function api_url() {
local request=$1 # info/binary
local platform=$2 # windows/linux/macos
# adoptopenjdk uses "mac" instead of "macos"
# adoptium uses "mac" instead of "macos"
if [[ $platform == "macos" ]]; then
platform="mac"
fi
echo -n "https://api.adoptopenjdk.net/v2/\
$request/releases/openjdk$JAVA_VERSION_BASE?\
openjdk_impl=$JVM_IMPL&\
os=$platform&\
arch=x64&\
type=$JAVA_DISTRO_TYPE"
echo -n "https://api.adoptium.net/v3/assets/feature_releases/\
$JAVA_VERSION_BASE/ga?architecture=x64&heap_size=normal&image_type=jdk&\
os=$platform&page=0&page_size=20&project=$JAVA_DISTRO_TYPE&\
sort_method=DEFAULT&sort_order=DESC&vendor=eclipse"
}
# requests info about all releases for given platform and java branch
@ -469,7 +469,7 @@ function find_latest_cached() {
# finds latest concrete distro version that matches version specified by user
function find_latest_version() {
local info=$1 # info fetched from AdoptOpenJDK
local info=$1 # info fetched from Adoptium
local user_version=$2 # version supplied by user is a template
local matched_version # latest version that matches the template
local versions # all versions
@ -495,12 +495,11 @@ function find_latest_version() {
# finds direct link to download concrete runtime version
function find_distro_link() {
local info=$1 # info fetched from AdoptOpenJDK
local info=$1 # info fetched from Adoptium
local version=$2 # concrete distro version like "11.0.2+9"
local link=$(echo "$info" \
| grep -B13 "\"heap_size\": \"normal\"" \
| grep -B11 "\"semver\": \"$version\"" \
| grep "binary_link" \
| grep -B14 "\"release_name\": \"jdk-$version\"" \
| grep "\"link\":" \
| sort --reverse \
| head -n 1 \
| awk '{print $2}' \