Skip to content

Commit

Permalink
feat(java): add jre variant installer (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Sep 3, 2021
1 parent 52b2def commit 7d37faa
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
48 changes: 48 additions & 0 deletions src/usr/local/buildpack/tools/java-jre.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

set -e

check_semver $TOOL_VERSION

if [[ ! "${MAJOR}" || ! "${MINOR}" || ! "${PATCH}" ]]; then
echo Invalid version: ${TOOL_VERSION}
exit 1
fi

tool_path=$(find_tool_path)

function update_env () {
reset_tool_env
export_tool_env JAVA_HOME "${1}"
export_tool_path "${1}/bin"
}

if [[ -z "${tool_path}" ]]; then
INSTALL_DIR=$(get_install_dir)
base_path=${INSTALL_DIR}/${TOOL_NAME}
tool_path=${base_path}/${TOOL_VERSION}

mkdir -p ${tool_path}

file=/tmp/java.tgz

ARCH=x64
URL=https://api.adoptium.net/v3/assets/version
API_ARGS='heap_size=normal&image_type=jre&os=linux&page=0&page_size=1&project=jdk&vendor=adoptium'

BIN_URL=$(curl -sSLf -H 'accept: application/json' "${URL}/${TOOL_VERSION}?architecture=${ARCH}&${API_ARGS}" \
| jq --raw-output '.[0].binaries[0].package.link')

curl -sSfLo ${file} ${BIN_URL}
tar --strip 1 -C ${tool_path} -xf ${file}
rm ${file}

update_env ${tool_path}

shell_wrapper java
else
echo "Already installed, resetting env"
update_env ${tool_path}
fi

java -version
5 changes: 4 additions & 1 deletion test/java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ RUN gradle --version
#--------------------------------------
# test: gradle 7
#--------------------------------------
FROM build as testb
FROM base as testb

# renovate: datasource=adoptium-java
RUN install-tool java-jre 11.0.12+7

# renovate: datasource=gradle-version versioning=gradle
RUN install-tool gradle 7.2
Expand Down

0 comments on commit 7d37faa

Please sign in to comment.