Skip to content

Commit

Permalink
Move jq query to function
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax committed Jan 20, 2025
1 parent 407c96a commit 0932454
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/jvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ else
DEFAULT_JDK_VERSION="1.8"
fi

read -d '' -r INVENTORY_QUERY <<'JQ_QUERY'
($raw_version_string | capture("((?<stack>[^-]*?)-)?(?<version>.*$)")) as $parsed_raw_version_string |
(.version_aliases[$parsed_raw_version_string.version] // $parsed_raw_version_string.version) as $version |
($parsed_raw_version_string.stack // $default_distribution) as $distribution |
.artifacts[] | select(.version == $version and .metadata.distribution == $distribution and .arch == "amd64" and .os == "linux" and (.metadata.cedar_stack? == null or .metadata.cedar_stack? == $stack))
JQ_QUERY

get_jdk_version() {
local appDir="${1:?}"

Expand All @@ -29,6 +22,13 @@ get_jdk_version() {
}

get_jdk_url() {
read -d '' -r INVENTORY_QUERY <<'INVENTORY_QUERY'
($raw_version_string | capture("((?<stack>[^-]*?)-)?(?<version>.*$)")) as $parsed_raw_version_string |
(.version_aliases[$parsed_raw_version_string.version] // $parsed_raw_version_string.version) as $version |
($parsed_raw_version_string.stack // $default_distribution) as $distribution |
.artifacts[] | select(.version == $version and .metadata.distribution == $distribution and .arch == "amd64" and .os == "linux" and (.metadata.cedar_stack? == null or .metadata.cedar_stack? == $stack))
INVENTORY_QUERY

jq <"${JVM_COMMON_DIR}/inventory.json" \
--arg raw_version_string "${1}" \
--arg default_distribution "zulu" \
Expand Down

0 comments on commit 0932454

Please sign in to comment.