Skip to content

Commit c904ebe

Browse files
committed
Fix tests
1 parent 57de00d commit c904ebe

6 files changed

Lines changed: 90 additions & 23 deletions

File tree

bin/test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ util::export_env_dir "${ENV_DIR}" "." "JAVA_OPTS|JAVA_TOOL_OPTIONS"
1717

1818
cd "${BUILD_DIR}"
1919

20-
settings_xml_opts="$(maven::settings_xml_opts "${BUILD_DIR}")"
20+
if ! settings_xml_opts="$(maven::settings_xml_opts "${BUILD_DIR}")"; then
21+
exit 1
22+
fi
2123

2224
if maven::should_use_wrapper "${BUILD_DIR}"; then
2325
# Intentional word splitting for settings_xml_opts

lib/maven.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ maven::setup_maven_and_build_app() {
4545
fi
4646

4747
local settings_xml_opts
48-
settings_xml_opts="$(maven::settings_xml_opts "${build_dir}")"
48+
if ! settings_xml_opts="$(maven::settings_xml_opts "${build_dir}")"; then
49+
exit 1
50+
fi
4951

5052
output::step "Executing Maven"
5153

@@ -233,7 +235,9 @@ maven::settings_xml_opts() {
233235
if [[ -n "${MAVEN_SETTINGS_PATH:-}" ]]; then
234236
settings_file=$(cd "${build_dir}" && realpath -m "${MAVEN_SETTINGS_PATH}")
235237
elif [[ -n "${MAVEN_SETTINGS_URL:-}" ]]; then
236-
settings_file=$(maven::download_settings_xml "${MAVEN_SETTINGS_URL}")
238+
if ! settings_file=$(maven::download_settings_xml "${MAVEN_SETTINGS_URL}"); then
239+
return 1
240+
fi
237241
elif [[ -f "${build_dir}/settings.xml" ]]; then
238242
settings_file="${build_dir}/settings.xml"
239243
fi
@@ -278,6 +282,6 @@ maven::download_settings_xml() {
278282
https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml
279283
EOF
280284

281-
exit 1
285+
return 1
282286
fi
283287
}

test/spec/customization_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
it 'allows to set custom Maven goals via MAVEN_CUSTOM_GOALS' do
77
app = Hatchet::Runner.new('simple-http-service', config: { MAVEN_CUSTOM_GOALS: 'site' })
88
app.deploy do
9-
expect(app.output).to include('./mvnw -DskipTests site')
9+
expect(app.output).to include('$ ./mvnw -DskipTests site')
1010
expect(app.output).to include('[INFO] --- maven-site-plugin:3.7.1:site (default-site) @ simple-http-service ---')
1111

1212
# The dependency list is implemented by using the dependency:list goal. We need to
@@ -40,7 +40,7 @@
4040
it 'allows to set custom Maven goals via MAVEN_CUSTOM_OPTS' do
4141
app = Hatchet::Runner.new('simple-http-service', config: { MAVEN_CUSTOM_OPTS: '-X' })
4242
app.deploy do
43-
expect(app.output).to include('./mvnw -X clean dependency:list install')
43+
expect(app.output).to include('$ ./mvnw -X clean dependency:list install')
4444
expect(app.output).to include('[DEBUG] -- end configuration --')
4545

4646
# -DskipTests is part of the default Maven options. We expect it to be overridden by MAVEN_CUSTOM_OPTS and

test/spec/misc_spec.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,24 @@
7373
remote: \\[ERROR\\] For more information about the errors and possible solutions, please read the following articles:
7474
remote: \\[ERROR\\] \\[Help 1\\] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
7575
remote:
76-
remote: ! ERROR: Failed to build app with Maven
76+
remote: ! Error: Maven build failed.
7777
remote: !
78-
remote: ! We're sorry this build is failing! If you can't find the issue in application code,
79-
remote: ! please submit a ticket so we can help: https://help.heroku.com/
78+
remote: ! An error occurred during the Maven build process. This usually
79+
remote: ! indicates an issue with your application's dependencies, configuration,
80+
remote: ! or source code.
81+
remote: !
82+
remote: ! First, check the build output above for specific error messages
83+
remote: ! from Maven that might indicate what went wrong. Common issues include:
84+
remote: !
85+
remote: ! - Missing or incompatible dependencies in your POM
86+
remote: ! - Compilation errors in your application source code
87+
remote: ! - Test failures \\(if tests are enabled during the build\\)
88+
remote: ! - Invalid Maven configuration or settings
89+
remote: ! - Using an incompatible OpenJDK version for your project
90+
remote: !
91+
remote: ! If you're unable to determine the cause from the Maven output,
92+
remote: ! try building your application locally with the same Maven command
93+
remote: ! to reproduce and debug the issue.
8094
remote:
8195
remote: ! Push rejected, failed to compile Java app.
8296
REGEX

test/spec/settings_xml_spec.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@
1717
config: { MAVEN_SETTINGS_URL: SETTINGS_XML_URL_404 })
1818
app.deploy do
1919
expect(clean_output(app.output)).to include(<<~OUTPUT)
20-
remote: -----> Executing Maven
21-
remote: $ ./mvnw -DskipTests clean dependency:list install
22-
remote: [ERROR] Error executing Maven.
23-
remote: [ERROR] 1 problem was encountered while building the effective settings
24-
remote: [FATAL] Non-parseable settings /tmp/codon/tmp/cache/.m2/settings.xml: only whitespace content allowed before start tag and not N (position: START_DOCUMENT seen N... @1:1) @ /tmp/codon/tmp/cache/.m2/settings.xml, line 1, column 1
25-
remote:
26-
remote:
27-
remote: ! ERROR: Failed to build app with Maven
20+
remote: ! Error: Unable to download Maven settings.xml.
21+
remote: !
22+
remote: ! An error occurred while downloading the Maven settings file from:
23+
remote: ! #{SETTINGS_XML_URL_404}
24+
remote: !
25+
remote: ! In some cases, this happens due to a temporary issue with
26+
remote: ! the network connection or server, or because the URL is
27+
remote: ! inaccessible or requires authentication.
28+
remote: !
29+
remote: ! Check that the URL in your MAVEN_SETTINGS_URL environment
30+
remote: ! variable is correct and publicly accessible. If the settings file
31+
remote: ! is not needed, you can remove the MAVEN_SETTINGS_URL environment variable
32+
remote: ! to use default Maven settings.
2833
remote: !
29-
remote: ! We're sorry this build is failing! If you can't find the issue in application code,
30-
remote: ! please submit a ticket so we can help: https://help.heroku.com/
34+
remote: ! Learn more about Maven settings configuration:
35+
remote: ! https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml
3136
remote:
3237
remote: ! Push rejected, failed to compile Java app.
3338
OUTPUT

test/spec/versions_spec.rb

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,30 @@
3838
expect(clean_output(app.output)).to include(<<~OUTPUT)
3939
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
4040
remote:
41-
remote: ! ERROR: You have defined an unsupported Maven version in the system.properties file.
41+
remote: ! Error: The requested Maven version isn't available.
4242
remote: !
43-
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}
43+
remote: ! Your app's system.properties file specifies a Maven version
44+
remote: ! of #{UNKNOWN_MAVEN_VERSION}, however, we couldn't find that version in the
45+
remote: ! Maven repository.
46+
remote: !
47+
remote: ! Check that this Maven version has been released upstream:
48+
remote: ! https://maven.apache.org/docs/history.html
49+
remote: !
50+
remote: ! If it has, make sure that you are using the latest version
51+
remote: ! of this buildpack, and haven't pinned to an older release:
52+
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#view-your-buildpacks
53+
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#classic-buildpacks-references
54+
remote: !
55+
remote: ! We also strongly recommend using the Maven Wrapper instead of
56+
remote: ! pinning to an exact Maven version such as #{UNKNOWN_MAVEN_VERSION}.
57+
remote: ! Remove the maven.version property from your system.properties file
58+
remote: ! and set up Maven Wrapper in your project, which will automatically
59+
remote: ! download and use the correct Maven version.
60+
remote: !
61+
remote: ! Learn more about Maven Wrapper:
62+
remote: ! https://maven.apache.org/wrapper/
63+
remote: !
64+
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}.
4465
remote:
4566
remote: ! Push rejected, failed to compile Java app.
4667
OUTPUT
@@ -73,9 +94,30 @@
7394
expect(clean_output(app.output)).to include(<<~OUTPUT)
7495
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
7596
remote:
76-
remote: ! ERROR: You have defined an unsupported Maven version in the system.properties file.
97+
remote: ! Error: The requested Maven version isn't available.
98+
remote: !
99+
remote: ! Your app's system.properties file specifies a Maven version
100+
remote: ! of #{UNKNOWN_MAVEN_VERSION}, however, we couldn't find that version in the
101+
remote: ! Maven repository.
102+
remote: !
103+
remote: ! Check that this Maven version has been released upstream:
104+
remote: ! https://maven.apache.org/docs/history.html
105+
remote: !
106+
remote: ! If it has, make sure that you are using the latest version
107+
remote: ! of this buildpack, and haven't pinned to an older release:
108+
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#view-your-buildpacks
109+
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#classic-buildpacks-references
110+
remote: !
111+
remote: ! We also strongly recommend using the Maven Wrapper instead of
112+
remote: ! pinning to an exact Maven version such as #{UNKNOWN_MAVEN_VERSION}.
113+
remote: ! Remove the maven.version property from your system.properties file
114+
remote: ! and set up Maven Wrapper in your project, which will automatically
115+
remote: ! download and use the correct Maven version.
116+
remote: !
117+
remote: ! Learn more about Maven Wrapper:
118+
remote: ! https://maven.apache.org/wrapper/
77119
remote: !
78-
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}
120+
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}.
79121
remote:
80122
remote: ! Push rejected, failed to compile Java app.
81123
OUTPUT

0 commit comments

Comments
 (0)