-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompile
More file actions
executable file
·108 lines (77 loc) · 2.65 KB
/
compile
File metadata and controls
executable file
·108 lines (77 loc) · 2.65 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir> <env-dir>
set -eo pipefail
if [[ -n "${BUILDPACK_DEBUG}" ]]; then
set -x
fi
build_dir="${1}"
cache_dir="${2}"
env_dir="${3}"
readonly java_version="${JAVA_VERSION:-1.8}"
readonly webapp_runner_version="${JAVA_WEBAPP_RUNNER_VERSION:-${WEBAPP_RUNNER_VERSION:-9.0.109.0}}"
readonly base_dir="$( cd -P "$( dirname "$0" )" && pwd )"
readonly buildpack_dir="$( readlink -f "${base_dir}/.." )"
source "${buildpack_dir}/lib/common.sh"
export_env_dir "${env_dir}"
# Installs Java and webapp_runner
#
# Usage: install_webapp_runner <build_dir> <cache_dir> <java_version> <webapp_runner_version>
#
install_webapp_runner() {
local jvm_url
local runner_url
local build_d
local cache_d
local buildpack_d
local tmp_d
local jre_version
local runner_version
local cached_jvm_common
local cached_runner
build_d="${1}"
cache_d="${2}"
buildpack_d="${3}"
jre_version="${4}"
runner_version="${5}"
local buildpacks_repository_url="https://buildpacks-repository.s3.eu-central-1.amazonaws.com"
jvm_url="${JVM_COMMON_BUILDPACK:-"${buildpacks_repository_url}/jvm-common.tar.xz"}"
runner_url="${buildpacks_repository_url}/webapp-runner-${runner_version}.jar"
echo "-----> Installing Webapp Runner ${runner_version}..."
# Install JVM common tools:
cached_jvm_common="${cache_d}/jvm-common.tar.xz"
if [ ! -f "${cached_jvm_common}" ]
then
curl --location --silent --retry 6 --retry-connrefused --retry-delay 0 \
"${jvm_url}" \
--output "${cached_jvm_common}"
fi
tmp_d=$( mktemp -d jvm-common-XXXXXX ) && {
tar --extract --xz --touch --strip-components=1 \
--file "${cached_jvm_common}" \
--directory "${tmp_d}"
# Source utilities and functions:
source "${tmp_d}/bin/java"
echo "java.runtime.version=${jre_version}" \
> "${build_d}/system.properties"
install_openjdk "${build_d}" "${buildpack_d}"
rm -Rf "${tmp_d}"
}
# Install Webapp Runner
cached_runner="${cache_d}/webapp-runner-${runner_version}.jar"
if [ ! -f "${cached_runner}" ]; then
echo "-----> Downloading webapp runner"
curl --location --silent --retry 6 --retry-connrefused --retry-delay 0 \
"${runner_url}" \
--output "${cached_runner}" \
|| {
echo "Unable to download webapp runner ${runner_version}. Aborting." >&2
exit 1
}
else
echo "-----> Got webapp runner from the cache"
fi
cp "${cached_runner}" "${build_d}/webapp-runner.jar"
}
readonly -f install_webapp_runner
install_webapp_runner "${build_dir}" "${cache_dir}" "${buildpack_dir}" \
"${java_version}" "${webapp_runner_version}"