diff --git a/lib/maven.sh b/lib/maven.sh index cc637c83..970c6c16 100644 --- a/lib/maven.sh +++ b/lib/maven.sh @@ -389,7 +389,7 @@ function maven::install_settings_xml() { Check that the URL in your MAVEN_SETTINGS_URL environment variable is correct and publicly accessible. If the settings file - is not needed, you can remove the MAVEN_SETTINGS_URL environment variable + is not needed, you can remove the MAVEN_SETTINGS_URL environment variable to use default Maven settings. Learn more about Maven settings configuration: diff --git a/lib/output.sh b/lib/output.sh index cbc967ae..9c994af1 100644 --- a/lib/output.sh +++ b/lib/output.sh @@ -4,6 +4,7 @@ ANSI_BLUE='\033[1;34m' ANSI_RED='\033[1;31m' ANSI_YELLOW='\033[1;33m' ANSI_RESET='\033[0m' +MESSAGE_INDENTATION=' ' # Output a single line step message to stdout. # @@ -36,10 +37,15 @@ function output::indent() { # EOF # ``` function output::notice() { - local line + local line indentation echo >&2 while IFS= read -r line; do - echo -e "${ANSI_BLUE} ! ${line}${ANSI_RESET}" >&2 + indentation="" + if [[ -n "${line}" ]]; then + indentation="${MESSAGE_INDENTATION}" + fi + + echo -e "${ANSI_BLUE} !${indentation}${line}${ANSI_RESET}" >&2 done echo >&2 } @@ -55,10 +61,15 @@ function output::notice() { # EOF # ``` function output::warning() { - local line + local line indentation echo >&2 while IFS= read -r line; do - echo -e "${ANSI_YELLOW} ! ${line}${ANSI_RESET}" >&2 + indentation="" + if [[ -n "${line}" ]]; then + indentation="${MESSAGE_INDENTATION}" + fi + + echo -e "${ANSI_YELLOW} !${indentation}${line}${ANSI_RESET}" >&2 done echo >&2 } @@ -74,10 +85,15 @@ function output::warning() { # EOF # ``` function output::error() { - local line + local line indentation echo >&2 while IFS= read -r line; do - echo -e "${ANSI_RED} ! ${line}${ANSI_RESET}" >&2 + indentation="" + if [[ -n "${line}" ]]; then + indentation="${MESSAGE_INDENTATION}" + fi + + echo -e "${ANSI_RED} !${indentation}${line}${ANSI_RESET}" >&2 done echo >&2 } diff --git a/test/spec/detection_spec.rb b/test/spec/detection_spec.rb index 4b92d51c..45ab6172 100644 --- a/test/spec/detection_spec.rb +++ b/test/spec/detection_spec.rb @@ -9,28 +9,28 @@ expect(clean_output(app.output)).to include(<<~OUTPUT) remote: ! Error: Your app is configured to use the Java buildpack, remote: ! but we couldn't find any supported Java project files. - remote: ! + remote: ! remote: ! The Java buildpack only supports Maven projects. It requires a pom.xml remote: ! file or other supported POM format in the root directory of your source code. - remote: ! + remote: ! remote: ! Supported POM formats: pom.xml, pom.atom, pom.clj, pom.groovy, pom.rb, pom.scala, pom.yaml, pom.yml - remote: ! + remote: ! remote: ! IMPORTANT: If your Java project uses a different build tool: remote: ! - For Gradle projects, use the heroku/gradle buildpack instead remote: ! - For sbt projects (including Play! Framework), use the heroku/scala buildpack instead - remote: ! + remote: ! remote: ! Currently the root directory of your app contains: - remote: ! + remote: ! remote: ! README.md - remote: ! + remote: ! remote: ! If your app already has a POM file, check that it: - remote: ! + remote: ! remote: ! 1. Is in the top level directory (not a subdirectory). remote: ! 2. Has the correct spelling (the filenames are case-sensitive). remote: ! 3. Isn't listed in '.gitignore' or '.slugignore'. remote: ! 4. Has been added to the Git repository using 'git add --all' remote: ! and then committed using 'git commit'. - remote: ! + remote: ! remote: ! For help with using Java on Heroku, see: remote: ! https://devcenter.heroku.com/articles/java-support OUTPUT diff --git a/test/spec/misc_spec.rb b/test/spec/misc_spec.rb index d13a5975..981138a8 100644 --- a/test/spec/misc_spec.rb +++ b/test/spec/misc_spec.rb @@ -72,26 +72,26 @@ remote: \\[ERROR\\] remote: \\[ERROR\\] For more information about the errors and possible solutions, please read the following articles: remote: \\[ERROR\\] \\[Help 1\\] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException - remote: + remote: remote: ! Error: Maven build failed. - remote: ! + remote: ! remote: ! An error occurred during the Maven build process. This usually remote: ! indicates an issue with your application's dependencies, configuration, remote: ! or source code. - remote: ! + remote: ! remote: ! First, check the build output above for specific error messages remote: ! from Maven that might indicate what went wrong. Common issues include: - remote: ! + remote: ! remote: ! - Missing or incompatible dependencies in your POM remote: ! - Compilation errors in your application source code remote: ! - Test failures \\(if tests are enabled during the build\\) remote: ! - Invalid Maven configuration or settings remote: ! - Using an incompatible OpenJDK version for your project - remote: ! + remote: ! remote: ! If you're unable to determine the cause from the Maven output, remote: ! try building your application locally with the same Maven command remote: ! to reproduce and debug the issue. - remote: + remote: remote: ! Push rejected, failed to compile Java app. REGEX end @@ -108,21 +108,21 @@ expect(app.output).to include('[INFO] BUILD SUCCESS') expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE)) remote: ! Warning: Maven Wrapper script found without properties file\\. - remote: ! + remote: ! remote: ! Found mvnw script but missing \\.mvn/wrapper/maven-wrapper\\.properties\\. remote: ! The Maven Wrapper requires both files to function properly\\. - remote: ! + remote: ! remote: ! To fix this issue, run this command in your project directory remote: ! locally and commit the generated files: remote: ! \\$ mvn wrapper:wrapper - remote: ! + remote: ! remote: ! Alternatively, if you don't want to use Maven Wrapper, you can remote: ! delete the mvnw file from your project, though the usage of the remote: ! Maven Wrapper is strongly recommended\\. - remote: ! + remote: ! remote: ! IMPORTANT: This warning will become an error in a future version remote: ! of this buildpack\\. Please fix this issue as soon as possible\\. - remote: ! + remote: ! remote: ! For more information about Maven Wrapper, see: remote: ! https://maven\\.apache\\.org/tools/wrapper/ remote: ! https://devcenter\\.heroku\\.com/articles/java-support#specifying-a-maven-version diff --git a/test/spec/settings_xml_spec.rb b/test/spec/settings_xml_spec.rb index eaf08024..86eca0b9 100644 --- a/test/spec/settings_xml_spec.rb +++ b/test/spec/settings_xml_spec.rb @@ -18,22 +18,22 @@ app.deploy do expect(clean_output(app.output)).to include(<<~OUTPUT) remote: ! Error: Unable to download Maven settings.xml. - remote: ! + remote: ! remote: ! An error occurred while downloading the Maven settings file from: remote: ! #{SETTINGS_XML_URL_404} - remote: ! + remote: ! remote: ! In some cases, this happens due to a temporary issue with remote: ! the network connection or server, or because the URL is remote: ! inaccessible or requires authentication. - remote: ! + remote: ! remote: ! Check that the URL in your MAVEN_SETTINGS_URL environment remote: ! variable is correct and publicly accessible. If the settings file - remote: ! is not needed, you can remove the MAVEN_SETTINGS_URL environment variable + remote: ! is not needed, you can remove the MAVEN_SETTINGS_URL environment variable remote: ! to use default Maven settings. - remote: ! + remote: ! remote: ! Learn more about Maven settings configuration: remote: ! https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml - remote: + remote: remote: ! Push rejected, failed to compile Java app. OUTPUT end @@ -147,12 +147,12 @@ app.deploy do expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE)) remote: ! Warning: Using existing settings\\.xml file\\. - remote: ! + remote: ! remote: ! A settings\\.xml file already exists at .*\\.m2/settings\\.xml\\. remote: ! However, the MAVEN_SETTINGS_PATH environment variable is set, which remote: ! would normally be used as the settings\\.xml configuration\\. The existing remote: ! file will be used\\. - remote: ! + remote: ! remote: ! If you intended to use the settings from MAVEN_SETTINGS_PATH instead, remote: ! remove the existing settings\\.xml file at .*\\.m2/settings\\.xml\\. REGEX @@ -180,12 +180,12 @@ app.deploy do expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE)) remote: ! Warning: Using existing settings\\.xml file\\. - remote: ! + remote: ! remote: ! A settings\\.xml file already exists at .*\\.m2/settings\\.xml\\. remote: ! However, the MAVEN_SETTINGS_URL environment variable is set, which remote: ! would normally be used as the settings\\.xml configuration\\. The existing remote: ! file will be used\\. - remote: ! + remote: ! remote: ! If you intended to use the settings from MAVEN_SETTINGS_URL instead, remote: ! remove the existing settings\\.xml file at .*\\.m2/settings\\.xml\\. REGEX @@ -215,12 +215,12 @@ app.deploy do expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE)) remote: ! Warning: Using existing settings\\.xml file\\. - remote: ! + remote: ! remote: ! A settings\\.xml file already exists at .*\\.m2/settings\\.xml\\. remote: ! However, a settings\\.xml file was also found in the project directory, remote: ! which would normally be used as the settings\\.xml configuration\\. The remote: ! existing file will be used\\. - remote: ! + remote: ! remote: ! If you intended to use the settings from your project directory instead, remote: ! remove the existing settings\\.xml file at .*\\.m2/settings\\.xml\\. REGEX diff --git a/test/spec/spec_helper.rb b/test/spec/spec_helper.rb index a7c43aad..2eab7a2f 100644 --- a/test/spec/spec_helper.rb +++ b/test/spec/spec_helper.rb @@ -58,4 +58,6 @@ def clean_output(output) .gsub(/ {8}(?=\R)/, '') # Remove ANSI colour codes used in buildpack output (e.g. error messages). .gsub(/\e\[[0-9;]+m/, '') + # Remove trailing space from empty "remote: " lines added by Heroku + .gsub(/^remote: $/, 'remote:') end diff --git a/test/spec/versions_spec.rb b/test/spec/versions_spec.rb index 022ce7ee..d844c28d 100644 --- a/test/spec/versions_spec.rb +++ b/test/spec/versions_spec.rb @@ -37,32 +37,32 @@ app.deploy do expect(clean_output(app.output)).to include(<<~OUTPUT) remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}... - remote: + remote: remote: ! Error: The requested Maven version isn't available. - remote: ! + remote: ! remote: ! Your app's system.properties file specifies a Maven version remote: ! of #{UNKNOWN_MAVEN_VERSION}, however, we couldn't find that version in the remote: ! Maven repository. - remote: ! + remote: ! remote: ! Check that this Maven version has been released upstream: remote: ! https://maven.apache.org/docs/history.html - remote: ! + remote: ! remote: ! If it has, make sure that you are using the latest version remote: ! of this buildpack, and haven't pinned to an older release: remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#view-your-buildpacks remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#classic-buildpacks-references - remote: ! + remote: ! remote: ! We also strongly recommend using the Maven Wrapper instead of remote: ! pinning to an exact Maven version such as #{UNKNOWN_MAVEN_VERSION}. remote: ! Remove the maven.version property from your system.properties file remote: ! and set up Maven Wrapper in your project, which will automatically remote: ! download and use the correct Maven version. - remote: ! + remote: ! remote: ! Learn more about Maven Wrapper: remote: ! https://maven.apache.org/wrapper/ - remote: ! + remote: ! remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}. - remote: + remote: remote: ! Push rejected, failed to compile Java app. OUTPUT end @@ -93,32 +93,32 @@ app.deploy do expect(clean_output(app.output)).to include(<<~OUTPUT) remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}... - remote: + remote: remote: ! Error: The requested Maven version isn't available. - remote: ! + remote: ! remote: ! Your app's system.properties file specifies a Maven version remote: ! of #{UNKNOWN_MAVEN_VERSION}, however, we couldn't find that version in the remote: ! Maven repository. - remote: ! + remote: ! remote: ! Check that this Maven version has been released upstream: remote: ! https://maven.apache.org/docs/history.html - remote: ! + remote: ! remote: ! If it has, make sure that you are using the latest version remote: ! of this buildpack, and haven't pinned to an older release: remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#view-your-buildpacks remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#classic-buildpacks-references - remote: ! + remote: ! remote: ! We also strongly recommend using the Maven Wrapper instead of remote: ! pinning to an exact Maven version such as #{UNKNOWN_MAVEN_VERSION}. remote: ! Remove the maven.version property from your system.properties file remote: ! and set up Maven Wrapper in your project, which will automatically remote: ! download and use the correct Maven version. - remote: ! + remote: ! remote: ! Learn more about Maven Wrapper: remote: ! https://maven.apache.org/wrapper/ - remote: ! + remote: ! remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}. - remote: + remote: remote: ! Push rejected, failed to compile Java app. OUTPUT end