Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

* Remove heroku-20 support ([#245](https://github.com/heroku/heroku-buildpack-java/pull/245))
* Buildpack output slightly changed. If you match against the buildpack output, verify your matching still works and adjust if necessary. ([#249](https://github.com/heroku/heroku-buildpack-java/pull/249))

## [v75] - 2025-02-24

Expand Down
1 change: 1 addition & 0 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV_DIR="${3}"

BUILDPACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"

source "${BUILDPACK_DIR}/lib/output.sh"
source "${BUILDPACK_DIR}/lib/util.sh"
source "${BUILDPACK_DIR}/lib/common.sh"
source "${BUILDPACK_DIR}/lib/maven.sh"
Expand Down
1 change: 1 addition & 0 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ BUILD_DIR="${1}"

BUILDPACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"

source "${BUILDPACK_DIR}/lib/output.sh"
source "${BUILDPACK_DIR}/lib/frameworks.sh"

echo "---"
Expand Down
1 change: 1 addition & 0 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV_DIR="${2}"

BUILDPACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"

source "${BUILDPACK_DIR}/lib/output.sh"
source "${BUILDPACK_DIR}/lib/util.sh"
source "${BUILDPACK_DIR}/lib/common.sh"
source "${BUILDPACK_DIR}/lib/maven.sh"
Expand Down
1 change: 1 addition & 0 deletions bin/test-compile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV_DIR="${3}"

BUILDPACK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"

source "${BUILDPACK_DIR}/lib/output.sh"
source "${BUILDPACK_DIR}/lib/util.sh"
source "${BUILDPACK_DIR}/lib/common.sh"
source "${BUILDPACK_DIR}/lib/maven.sh"
Expand Down
12 changes: 6 additions & 6 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ common::install_maven() {

local maven_version="${defined_maven_version:-${DEFAULT_MAVEN_VERSION}}"

status_pending "Installing Maven ${maven_version}"
output::step "Installing Maven ${maven_version}..."
local maven_url="https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${maven_version}/apache-maven-${maven_version}-bin.tar.gz"
if common::is_supported_maven_version "${maven_version}" "${maven_url}"; then
common::download_maven "${maven_url}" "${maven_home}"
status_done
else
error_return "Error, you have defined an unsupported Maven version in the system.properties file.
The default supported version is ${DEFAULT_MAVEN_VERSION}"
output::error <<-EOF
ERROR: You have defined an unsupported Maven version in the system.properties file.

The default supported version is ${DEFAULT_MAVEN_VERSION}
EOF
return 1
fi
}
Expand Down Expand Up @@ -98,8 +100,6 @@ common::install_jdk() {
mkdir -p /tmp/jvm-common
curl --fail --retry 3 --retry-connrefused --connect-timeout 5 --silent --location "${JVM_COMMON_BUILDPACK}" | tar xzm -C /tmp/jvm-common --strip-components=1
#shellcheck source=/dev/null
source /tmp/jvm-common/bin/util
#shellcheck source=/dev/null
source /tmp/jvm-common/bin/java
#shellcheck source=/dev/null
source /tmp/jvm-common/opt/jdbc.sh
Expand Down
20 changes: 13 additions & 7 deletions lib/maven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ maven::mvn_settings_opt() {
if [[ -f "${settings_xml}" ]]; then
echo -n "-s ${settings_xml}"
else
error "Could not download settings.xml from the URL defined in MAVEN_SETTINGS_URL!"
output::error <<-EOF
ERROR: Could not download settings.xml from the URL defined in MAVEN_SETTINGS_URL!
Comment thread
Malax marked this conversation as resolved.
EOF
return 1
fi
elif [[ -f "${home}/settings.xml" ]]; then
Expand Down Expand Up @@ -98,15 +100,19 @@ maven::run_mvn() {
local mvn_opts
mvn_opts="$(maven::mvn_cmd_opts "${scope}")"

status "Executing Maven"
echo "$ ${maven_exe} ${mvn_opts}" | indent
output::step "Executing Maven"
echo "$ ${maven_exe} ${mvn_opts}" | output::indent

# We rely on word splitting for mvn_settings_opt and mvn_opts:
# shellcheck disable=SC2086
if ! ${maven_exe} -DoutputFile=target/mvn-dependency-list.log -B ${mvn_settings_opt} ${mvn_opts} | indent; then
error "Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/"
if ! ${maven_exe} -DoutputFile=target/mvn-dependency-list.log -B ${mvn_settings_opt} ${mvn_opts} | output::indent; then
output::error <<-EOF
ERROR: Failed to build app with Maven

We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
EOF
return 1
fi
}

Expand Down
83 changes: 83 additions & 0 deletions lib/output.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

ANSI_BLUE='\033[1;34m'
ANSI_RED='\033[1;31m'
ANSI_YELLOW='\033[1;33m'
ANSI_RESET='\033[0m'

# Output a single line step message to stdout.
#
# Usage:
# ```
# output::step "Installing Python ..."
# ```
function output::step() {
echo "-----> ${1}"
}

# Indent passed stdout. Typically used to indent command output within a step.
#
# Usage:
# ```
# pip install ... | output::indent
# ```
function output::indent() {
sed --unbuffered "s/^/ /"
}

# Output a styled multi-line notice message to stderr.
#
# Usage:
# ```
# output::notice <<-EOF
# Note: The note summary.
#
# Detailed description.
# EOF
# ```
function output::notice() {
local line
echo >&2
while IFS= read -r line; do
echo -e "${ANSI_BLUE} ! ${line}${ANSI_RESET}" >&2
done
echo >&2
}

# Output a styled multi-line warning message to stderr.
#
# Usage:
# ```
# output::warning <<-EOF
# Warning: The warning summary.
#
# Detailed description.
# EOF
# ```
function output::warning() {
local line
echo >&2
while IFS= read -r line; do
echo -e "${ANSI_YELLOW} ! ${line}${ANSI_RESET}" >&2
done
echo >&2
}

# Output a styled multi-line error message to stderr.
#
# Usage:
# ```
# output::error <<-EOF
# Error: The error summary.
#
# Detailed description.
# EOF
# ```
function output::error() {
local line
echo >&2
while IFS= read -r line; do
echo -e "${ANSI_RED} ! ${line}${ANSI_RESET}" >&2
done
echo >&2
}
5 changes: 3 additions & 2 deletions test/spec/misc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
remote: \\[ERROR\\] \\[Help 1\\] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
remote:
remote: ! ERROR: Failed to build app with Maven
remote: We're sorry this build is failing! If you can't find the issue in application code,
remote: please submit a ticket so we can help: https://help.heroku.com/
remote: !
remote: ! We're sorry this build is failing! If you can't find the issue in application code,
remote: ! please submit a ticket so we can help: https://help.heroku.com/
remote:
remote: ! Push rejected, failed to compile Java app.
REGEX
Expand Down
5 changes: 3 additions & 2 deletions test/spec/settings_xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
remote:
remote:
remote: ! ERROR: Failed to build app with Maven
remote: We're sorry this build is failing! If you can't find the issue in application code,
remote: please submit a ticket so we can help: https://help.heroku.com/
remote: !
remote: ! We're sorry this build is failing! If you can't find the issue in application code,
remote: ! please submit a ticket so we can help: https://help.heroku.com/
remote:
remote: ! Push rejected, failed to compile Java app.
OUTPUT
Expand Down
18 changes: 11 additions & 7 deletions test/spec/versions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

app.deploy do
expect(clean_output(app.output)).not_to include('$ ./mvnw')
expect(clean_output(app.output)).to include("remote: -----> Installing Maven #{DEFAULT_MAVEN_VERSION}... done")
expect(clean_output(app.output)).to include("remote: -----> Installing Maven #{DEFAULT_MAVEN_VERSION}...")
expect(clean_output(app.output)).to(
include("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] #{DEFAULT_MAVEN_VERSION}")
)
Expand All @@ -37,8 +37,10 @@
app.deploy do
expect(clean_output(app.output)).to include(<<~OUTPUT)
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
remote: ! ERROR: Error, you have defined an unsupported Maven version in the system.properties file.
remote: The default supported version is #{DEFAULT_MAVEN_VERSION}
remote:
remote: ! ERROR: You have defined an unsupported Maven version in the system.properties file.
remote: !
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}
remote:
remote: ! Push rejected, failed to compile Java app.
OUTPUT
Expand All @@ -53,7 +55,7 @@

app.deploy do
expect(clean_output(app.output)).not_to include('$ ./mvnw')
expect(clean_output(app.output)).to include("remote: -----> Installing Maven #{DEFAULT_MAVEN_VERSION}... done")
expect(clean_output(app.output)).to include("remote: -----> Installing Maven #{DEFAULT_MAVEN_VERSION}...")
expect(clean_output(app.output)).to(
include("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] #{DEFAULT_MAVEN_VERSION}")
)
Expand All @@ -70,8 +72,10 @@
app.deploy do
expect(clean_output(app.output)).to include(<<~OUTPUT)
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
remote: ! ERROR: Error, you have defined an unsupported Maven version in the system.properties file.
remote: The default supported version is #{DEFAULT_MAVEN_VERSION}
remote:
remote: ! ERROR: You have defined an unsupported Maven version in the system.properties file.
remote: !
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}
remote:
remote: ! Push rejected, failed to compile Java app.
OUTPUT
Expand All @@ -87,7 +91,7 @@

app.deploy do
expect(clean_output(app.output)).not_to include('$ ./mvnw')
expect(clean_output(app.output)).to include('remote: -----> Installing Maven 3.9.4... done')
expect(clean_output(app.output)).to include('remote: -----> Installing Maven 3.9.4...')
expect(clean_output(app.output)).to include('[BUILDPACK INTEGRATION TEST - MAVEN VERSION] 3.9.4')
end
end
Expand Down