Skip to content

Commit bd33f81

Browse files
committed
Remove buildpack stdlib
1 parent ff5a5cc commit bd33f81

File tree

7 files changed

+24
-202
lines changed

7 files changed

+24
-202
lines changed

bin/compile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/usr/bin/env bash
22
# bin/compile <build-dir> <cache-dir> <env-dir>
33

4-
# fail fast
54
set -e
65

7-
BPLOG_PREFIX="buildpack.java"
8-
96
BP_DIR=$(
107
cd "$(dirname "${0}")/"..
118
pwd
@@ -15,9 +12,9 @@ BUILD_DIR=$1
1512
CACHE_DIR=$2
1613
ENV_DIR=$3
1714

15+
source "${BP_DIR}/lib/util.sh"
1816
source "${BP_DIR}/lib/common.sh"
1917
source "${BP_DIR}/lib/maven.sh"
20-
source "${BP_DIR}/lib/buildpack-stdlib-v7.sh"
2118
source "${BP_DIR}/lib/metadata.sh"
2219

2320
# Initialise the buildpack metadata store.
@@ -26,12 +23,9 @@ source "${BP_DIR}/lib/metadata.sh"
2623
meta_init "${CACHE_DIR}" "java"
2724
meta_setup
2825

29-
export_env "${ENV_DIR}" "." "JAVA_OPTS|JAVA_TOOL_OPTIONS"
26+
export_env_dir "${ENV_DIR}" "." "JAVA_OPTS|JAVA_TOOL_OPTIONS"
3027

3128
install_jdk "${BUILD_DIR}" "${CACHE_DIR}"
3229

33-
[ -n "$(find "${BUILD_DIR}" -type f -name "*.kt")" ] && mcount "kotlin.source"
34-
[ -n "$(find "${BUILD_DIR}" -type f -name "*.groovy")" ] && mcount "groovy.source"
35-
3630
run_mvn "compile" "${BUILD_DIR}" "${CACHE_DIR}"
3731
remove_mvn "${BUILD_DIR}" "${CACHE_DIR}"

bin/test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ ENV_DIR=$2
1313

1414
source "${BP_DIR}/lib/common.sh"
1515
source "${BP_DIR}/lib/maven.sh"
16-
source "${BP_DIR}/lib/buildpack-stdlib-v7.sh"
1716

18-
export_env "${ENV_DIR}" "." "JAVA_OPTS|JAVA_TOOL_OPTIONS"
17+
export_env_dir "${ENV_DIR}" "." "JAVA_OPTS|JAVA_TOOL_OPTIONS"
1918

2019
cd "${BUILD_DIR}"
2120

bin/test-compile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ ENV_DIR=$3
1717

1818
source "${BP_DIR}/lib/common.sh"
1919
source "${BP_DIR}/lib/maven.sh"
20-
source "${BP_DIR}/lib/buildpack-stdlib-v7.sh"
2120

22-
export_env "${ENV_DIR}" "." "JAVA_OPTS|JAVA_TOOL_OPTIONS"
21+
export_env_dir "${ENV_DIR}" "." "JAVA_OPTS|JAVA_TOOL_OPTIONS"
2322

2423
install_jdk "${BUILD_DIR}"
2524

lib/buildpack-stdlib-v7.sh

Lines changed: 0 additions & 166 deletions
This file was deleted.

lib/common.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ install_maven() {
1010
definedMavenVersion=$(detect_maven_version "${buildDir}")
1111

1212
mavenVersion=${definedMavenVersion:-$DEFAULT_MAVEN_VERSION}
13-
mcount "mvn.version.${mavenVersion}"
1413

1514
status_pending "Installing Maven ${mavenVersion}"
1615
local mavenUrl="https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${mavenVersion}/apache-maven-${mavenVersion}-bin.tar.gz"
@@ -89,9 +88,6 @@ install_jdk() {
8988
local install_dir=${1}
9089
local cache_dir=${2}
9190

92-
local start
93-
start=$(nowms)
94-
9591
JVM_COMMON_BUILDPACK=${JVM_COMMON_BUILDPACK:-https://buildpack-registry.s3.us-east-1.amazonaws.com/buildpacks/heroku/jvm.tgz}
9692
mkdir -p /tmp/jvm-common
9793
curl --fail --retry 3 --retry-connrefused --connect-timeout 5 --silent --location "${JVM_COMMON_BUILDPACK}" | tar xzm -C /tmp/jvm-common --strip-components=1
@@ -101,9 +97,6 @@ install_jdk() {
10197
source /tmp/jvm-common/bin/java
10298
#shellcheck source=/dev/null
10399
source /tmp/jvm-common/opt/jdbc.sh
104-
mtime "jvm-common.install.time" "${start}"
105100

106-
start=$(nowms)
107101
install_java_with_overlay "${install_dir}" "${cache_dir}"
108-
mtime "jvm.install.time" "${start}"
109102
}

lib/maven.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,20 @@ _mvn_settings_opt() {
3333
local mavenInstallDir="${2}"
3434

3535
if [ -n "$MAVEN_SETTINGS_PATH" ]; then
36-
mcount "mvn.settings.path"
3736
echo -n "-s $MAVEN_SETTINGS_PATH"
3837
elif [ -n "$MAVEN_SETTINGS_URL" ]; then
3938
local settingsXml="${mavenInstallDir}/.m2/settings.xml"
4039
mkdir -p "$(dirname "${settingsXml}")"
4140
curl --retry 3 --retry-connrefused --connect-timeout 5 --silent --max-time 10 --location "${MAVEN_SETTINGS_URL}" --output "${settingsXml}"
42-
mcount "mvn.settings.url"
4341
if [ -f "${settingsXml}" ]; then
4442
echo -n "-s ${settingsXml}"
4543
else
46-
mcount "mvn.settings.url.fail"
4744
error "Could not download settings.xml from the URL defined in MAVEN_SETTINGS_URL!"
4845
return 1
4946
fi
5047
elif [ -f "${home}/settings.xml" ]; then
51-
mcount "mvn.settings.file"
5248
echo -n "-s ${home}/settings.xml"
5349
else
54-
mcount "mvn.settings.default"
5550
echo -n ""
5651
fi
5752
}
@@ -86,15 +81,11 @@ run_mvn() {
8681
cache_copy ".m2/wrapper" "${mavenInstallDir}" "${home}"
8782
chmod +x "${home}/mvnw"
8883
local mavenExe="./mvnw"
89-
mcount "mvn.version.wrapper"
9084
else
9185
# shellcheck disable=SC2164
9286
cd "${mavenInstallDir}"
93-
local start
94-
start=$(nowms)
9587

9688
install_maven "${mavenInstallDir}" "${home}"
97-
mtime "mvn.${scope}.time" "${start}"
9889
PATH="${mavenInstallDir}/.maven/bin:$PATH"
9990
local mavenExe="mvn"
10091
# shellcheck disable=SC2164
@@ -115,21 +106,13 @@ run_mvn() {
115106
status "Executing Maven"
116107
echo "$ ${mavenExe} ${mvnOpts}" | indent
117108

118-
local cache_status
119-
cache_status="$(get_cache_status "${mavenInstallDir}")"
120-
local start
121-
start=$(nowms)
122-
123109
# We rely on word splitting for mvn_settings_opt and mvnOpts:
124110
# shellcheck disable=SC2086
125111
if ! ${mavenExe} -DoutputFile=target/mvn-dependency-list.log -B ${mvn_settings_opt} ${mvnOpts} | indent; then
126112
error "Failed to build app with Maven
127113
We're sorry this build is failing! If you can't find the issue in application code,
128114
please submit a ticket so we can help: https://help.heroku.com/"
129115
fi
130-
131-
mtime "mvn.${scope}.time" "${start}"
132-
mtime "mvn.${scope}.time.cache.${cache_status}" "${start}"
133116
}
134117

135118
write_mvn_profile() {

lib/util.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
export_env_dir() {
4+
env_dir=$1
5+
whitelist_regex=${2:-''}
6+
blacklist_regex=${3:-'^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH|JAVA_OPTS|JAVA_TOOL_OPTIONS)$'}
7+
if [ -d "$env_dir" ]; then
8+
for env_var_path in "$env_dir"/*; do
9+
if [ -f "$env_var_path" ]; then
10+
basename "$env_var_path" | grep -E "$whitelist_regex" | grep -qvE "$blacklist_regex" &&
11+
export "$(basename "$env_var_path")=$(cat "$env_var_path")"
12+
fi
13+
:
14+
done
15+
fi
16+
}
17+
18+
nowms() {
19+
date +%s%3N
20+
}

0 commit comments

Comments
 (0)