asdf-java/update_data.bash
Wessel van Norel 150e793d43
Add the JVM Implementation after the name of the Vendor (#140)
* To fix https://github.com/halcyon/asdf-java/issues/46 and https://github.com/halcyon/asdf-java/issues/57 added the jvm_impl after the vendor if it's not the hotspot jvm

* Only openj9 is special case, hotspot and graalvm should be ignored

* Suppress grep output, but show message about what is found. In case the test fails this helps to see what part broke.

* Added testcase for the graalvm-graalvm I accidentally introduced, so this won't happen in the future
2021-04-06 16:14:33 -04:00

55 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
set -Euo pipefail
# See https://joschi.github.io/java-metadata/ for supported values
LIST_OS="linux macosx"
LIST_ARCH="x86_64 aarch64 arm32-vfp-hflt"
DATA_DIR="./data"
if [[ ! -d "${DATA_DIR}" ]]
then
mkdir "${DATA_DIR}"
fi
function metadata_url {
local os=$1
local arch=$2
echo "https://joschi.github.io/java-metadata/metadata/ga/${os}/${arch}/jdk.json"
}
function fetch_metadata {
local os=$1
local arch=$2
local url
url=$(metadata_url "$os" "$arch")
local args=('-s' '-f' '--compressed' '-H' "Accept: application/json")
if [[ -n "${GITHUB_API_TOKEN:-}" ]]; then
args+=('-H' "Authorization: token $GITHUB_API_TOKEN")
fi
curl "${args[@]}" -o "${DATA_DIR}/jdk-${os}-${arch}.json" "${url}"
}
for OS in $LIST_OS
do
for ARCH in $LIST_ARCH
do
fetch_metadata "$OS" "$ARCH"
done
done
RELEASE_QUERY='.[]
| select(.file_type | IN("tar.gz", "zip"))
| .["features"] = (.features | map(select(IN("musl", "javafx", "lite", "large_heap"))))
| [([.vendor, if (.jvm_impl == "openj9") then .jvm_impl else empty end, if ((.features | length) == 0) then empty else (.features | join("-")) end, .version] | join("-")), .filename, .url, .sha256]
| @tsv'
for FILE in "${DATA_DIR}"/*.json
do
TSV_FILE="$(basename "${FILE}" .json).tsv"
jq -r "${RELEASE_QUERY}" "${FILE}" | sort -V > "${DATA_DIR}/${TSV_FILE}"
done