-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.rb
33 lines (29 loc) · 1.54 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Olp < Formula
desc "With the Command Line Interface you can access HERE platform services from a command line or with scripts."
homepage "https://platform.in.here.com/sdk/cli"
url "https://artifact.api.platform.here.com/v1/references/hrn:here:artifact:::com.here.platform:cli:${OLP_CLI_VERSION}/cli-${OLP_CLI_VERSION}.tar.gz\?apiKey\=${ARTIFACT_SERVICE_API_KEY}"
sha256 "${SHA256}"
version "${OLP_CLI_VERSION}"
license "Proprietary"
depends_on "openjdk@17"
def install
prefix.install "HERE_NOTICE"
prefix.install "LICENSE"
libexec.install "cli${SCALA_SUFFIX}-${OLP_CLI_VERSION}.jar"
# There are two versions of variables: build time and runtime
# JAVA_VERSION, ALLOW_DEEP_REFLECTION, 2 and @ needs to be preserved during build time by using § instead of $
(bin/"olp").write <<~EOS
#!/bin/bash
export JAVA_HOME="#{Language::Java.overridable_java_home_env("17")[:JAVA_HOME]}"
JAVA_VERSION=$(§{JAVA_HOME}/bin/java -Xms32M -Xmx32M -version 2>&1 | awk -F '"' '/version/ {print §2}')
# Check for '1.' entry because starting from JDK 9 version numbering is different (1.8 vs 9.0/10.0/11.0/... )
if ! [[ "§JAVA_VERSION" =~ ^1"."+ ]]; then
ALLOW_DEEP_REFLECTION="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED"
fi
exec "§{JAVA_HOME}/bin/java" §{ALLOW_DEEP_REFLECTION:-} -Dfile.encoding=UTF8 -jar "#{libexec}/cli${SCALA_SUFFIX}-${OLP_CLI_VERSION}.jar" "§@"
EOS
end
test do
system bin/"olp", "version", "--help"
end
end