diff --git a/bin/compile b/bin/compile index 068ffa82..8413b334 100755 --- a/bin/compile +++ b/bin/compile @@ -6,7 +6,10 @@ set -e BPLOG_PREFIX="buildpack.java" -BP_DIR=$(cd $(dirname $0)/..; pwd) # absolute path +BP_DIR=$( + cd $(dirname $0)/.. + pwd +) # absolute path BUILD_DIR=$1 CACHE_DIR=$2 ENV_DIR=$3 diff --git a/bin/detect b/bin/detect index be1b953b..8d1a2bf5 100755 --- a/bin/detect +++ b/bin/detect @@ -1,16 +1,16 @@ #!/usr/bin/env bash if [ -f "${1:?}/pom.xml" ] || - [ -f "${1:?}/pom.atom" ] || - [ -f "${1:?}/pom.clj" ] || - [ -f "${1:?}/pom.groovy" ] || - [ -f "${1:?}/pom.rb" ] || - [ -f "${1:?}/pom.scala" ] || - [ -f "${1:?}/pom.yaml" ] || - [ -f "${1:?}/pom.yml" ] ; then - echo "Java" - exit 0 + [ -f "${1:?}/pom.atom" ] || + [ -f "${1:?}/pom.clj" ] || + [ -f "${1:?}/pom.groovy" ] || + [ -f "${1:?}/pom.rb" ] || + [ -f "${1:?}/pom.scala" ] || + [ -f "${1:?}/pom.yaml" ] || + [ -f "${1:?}/pom.yml" ]; then + echo "Java" + exit 0 else - (>&2 echo "Could not find a pom.xml file! Please check that it exists and is committed to Git.") - exit 1 + (>&2 echo "Could not find a pom.xml file! Please check that it exists and is committed to Git.") + exit 1 fi diff --git a/bin/release b/bin/release index 88aa8f85..ac14ef3e 100755 --- a/bin/release +++ b/bin/release @@ -1,7 +1,10 @@ #!/usr/bin/env bash # bin/release -BP_DIR=$(cd $(dirname $0)/..; pwd) # absolute path +BP_DIR=$( + cd $(dirname $0)/.. + pwd +) # absolute path BUILD_DIR=$1 source $BP_DIR/lib/frameworks.sh @@ -9,30 +12,30 @@ source $BP_DIR/lib/frameworks.sh echo "---" if has_postgres $BUILD_DIR; then - cat <> $PROFILE_PATH - echo "export $1=$2" >> $EXPORT_PATH + # TODO: automatically create profile path directory if it doesn't exist. + echo "export $1=$2" >>$PROFILE_PATH + echo "export $1=$2" >>$EXPORT_PATH } # Usage: $ set-default-env key value # NOTICE: Expects PROFILE_PATH & EXPORT_PATH to be set! set_default_env() { - echo "export $1=\${$1:-$2}" >> $PROFILE_PATH - echo "export $1=\${$1:-$2}" >> $EXPORT_PATH + echo "export $1=\${$1:-$2}" >>$PROFILE_PATH + echo "export $1=\${$1:-$2}" >>$EXPORT_PATH } # Usage: $ un-set-env key # NOTICE: Expects PROFILE_PATH to be set! un_set_env() { - echo "unset $1" >> $PROFILE_PATH + echo "unset $1" >>$PROFILE_PATH } # Usage: $ _env-blacklist pattern # Outputs a regex of default blacklist env vars. _env_blacklist() { - local regex=${1:-''} - if [ -n "$regex" ]; then - regex="|$regex" - fi - echo "^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH$regex)$" + local regex=${1:-''} + if [ -n "$regex" ]; then + regex="|$regex" + fi + echo "^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH$regex)$" } # Usage: $ export-env ENV_DIR WHITELIST BLACKLIST # Exports the environment variables defined in the given directory. export_env() { - local env_dir=${1:-$ENV_DIR} - local whitelist=${2:-''} - local blacklist="$(_env_blacklist $3)" - if [ -d "$env_dir" ]; then - for e in $(ls $env_dir); do - echo "$e" | grep -E "$whitelist" | grep -qvE "$blacklist" && - export "$e=$(cat $env_dir/$e)" - : - done - fi + local env_dir=${1:-$ENV_DIR} + local whitelist=${2:-''} + local blacklist="$(_env_blacklist $3)" + if [ -d "$env_dir" ]; then + for e in $(ls $env_dir); do + echo "$e" | grep -E "$whitelist" | grep -qvE "$blacklist" && + export "$e=$(cat $env_dir/$e)" + : + done + fi } # Usage: $ sub-env command @@ -94,11 +93,11 @@ export_env() { # WHITELIST=${2:-''} # BLACKLIST=${3:-'^(GIT_DIR|PYTHONHOME|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)$'} sub_env() { - ( - export_env $ENV_DIR $WHITELIST $BLACKLIST + ( + export_env $ENV_DIR $WHITELIST $BLACKLIST - $1 - ) + $1 + ) } # Logging @@ -110,55 +109,55 @@ sub_env() { # Returns now, in milleseconds. Useful for logging. # Example: $ let start=$(nowms); sleep 30; mtime "glide.install.time" "${start}" nowms() { - date +%s%3N + date +%s%3N } # Log arbitrary data to the logfile (e.g. a packaging file). # Usage: $ bplog "$(<${vendorJSON}) bplog() { - echo -n ${@} | awk 'BEGIN {printf "msg=\""; f="%s"} {gsub(/"/, "\\\"", $0); printf f, $0} {if (NR == 1) f="\\n%s" } END { print "\"" }' >> ${BUILDPACK_LOG_FILE} + echo -n ${@} | awk 'BEGIN {printf "msg=\""; f="%s"} {gsub(/"/, "\\\"", $0); printf f, $0} {if (NR == 1) f="\\n%s" } END { print "\"" }' >>${BUILDPACK_LOG_FILE} } # Measures time elapsed for a specific build step. # Usage: $ let start=$(nowms); mtime "glide.install.time" "${start}" # https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#distributions-measure mtime() { - local key="${BPLOG_PREFIX}.${1}" - local start="${2}" - local end="${3:-$(nowms)}" - echo "${key} ${start} ${end}" | awk '{ printf "measure#%s=%.3f\n", $1, ($3 - $2)/1000 }' >> ${BUILDPACK_LOG_FILE} + local key="${BPLOG_PREFIX}.${1}" + local start="${2}" + local end="${3:-$(nowms)}" + echo "${key} ${start} ${end}" | awk '{ printf "measure#%s=%.3f\n", $1, ($3 - $2)/1000 }' >>${BUILDPACK_LOG_FILE} } # Logs a count for a specific built step. # Usage: $ mcount "tool.govendor" # https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#counting-count mcount() { - local k="${BPLOG_PREFIX}.${1}" - local v="${2:-1}" - echo "count#${k}=${v}" >> ${BUILDPACK_LOG_FILE} + local k="${BPLOG_PREFIX}.${1}" + local v="${2:-1}" + echo "count#${k}=${v}" >>${BUILDPACK_LOG_FILE} } # Logs a measure for a specific build step. # Usage: $ mmeasure "tool.installed_dependencies" 42 # https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#distributions-measure mmeasure() { - local k="${BPLOG_PREFIX}.${1}" - local v="${2}" - echo "measure#${k}=${v}" >> ${BUILDPACK_LOG_FILE} + local k="${BPLOG_PREFIX}.${1}" + local v="${2}" + echo "measure#${k}=${v}" >>${BUILDPACK_LOG_FILE} } # Logs a unuique measurement build step. # Usage: $ munique "versions.count" 2.7.13 # https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#uniques-unique munique() { - local k="${BPLOG_PREFIX}.${1}" - local v="${2}" - echo "unique#${k}=${v}" >> ${BUILDPACK_LOG_FILE} + local k="${BPLOG_PREFIX}.${1}" + local v="${2}" + echo "unique#${k}=${v}" >>${BUILDPACK_LOG_FILE} } # Measures when an exit path to the buildpack is reached, given a name, then exits 1. # Usage: $ mcount-exi "binExists" mcount_exit() { - mcount "error.${1}" - exit 1 + mcount "error.${1}" + exit 1 } diff --git a/lib/common.sh b/lib/common.sh index 1d81e6cd..dd26c2d9 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -3,100 +3,100 @@ export DEFAULT_MAVEN_VERSION="3.9.4" install_maven() { - local installDir=$1 - local buildDir=$2 - mavenHome=$installDir/.maven - - definedMavenVersion=$(detect_maven_version $buildDir) - - mavenVersion=${definedMavenVersion:-$DEFAULT_MAVEN_VERSION} - mcount "mvn.version.${mavenVersion}" - - status_pending "Installing Maven ${mavenVersion}" - local mavenUrl="https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${mavenVersion}/apache-maven-${mavenVersion}-bin.tar.gz" - if is_supported_maven_version "${mavenVersion}" "${mavenUrl}"; then - download_maven "${mavenUrl}" "${mavenHome}" - status_done - else - error_return "Error, you have defined an unsupported Maven version in the system.properties file. + local installDir=$1 + local buildDir=$2 + mavenHome=$installDir/.maven + + definedMavenVersion=$(detect_maven_version $buildDir) + + mavenVersion=${definedMavenVersion:-$DEFAULT_MAVEN_VERSION} + mcount "mvn.version.${mavenVersion}" + + status_pending "Installing Maven ${mavenVersion}" + local mavenUrl="https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${mavenVersion}/apache-maven-${mavenVersion}-bin.tar.gz" + if is_supported_maven_version "${mavenVersion}" "${mavenUrl}"; then + download_maven "${mavenUrl}" "${mavenHome}" + 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}" - return 1 - fi + return 1 + fi } download_maven() { - local mavenUrl=$1 - local installDir=$2 + local mavenUrl=$1 + local installDir=$2 - rm -rf $installDir - mkdir -p $installDir - curl --fail --retry 3 --retry-connrefused --connect-timeout 5 --silent --max-time 60 --location "${mavenUrl}" | tar -xzm --strip-components 1 -C $installDir - chmod +x $installDir/bin/mvn + rm -rf $installDir + mkdir -p $installDir + curl --fail --retry 3 --retry-connrefused --connect-timeout 5 --silent --max-time 60 --location "${mavenUrl}" | tar -xzm --strip-components 1 -C $installDir + chmod +x $installDir/bin/mvn } is_supported_maven_version() { - local mavenVersion=${1} - local mavenUrl=${2:?} - if [ "$mavenVersion" = "$DEFAULT_MAVEN_VERSION" ]; then - return 0 - elif curl -I --retry 3 --retry-connrefused --connect-timeout 5 --fail --silent --max-time 5 --location "${mavenUrl}" > /dev/null; then - return 0 - else - return 1 - fi + local mavenVersion=${1} + local mavenUrl=${2:?} + if [ "$mavenVersion" = "$DEFAULT_MAVEN_VERSION" ]; then + return 0 + elif curl -I --retry 3 --retry-connrefused --connect-timeout 5 --fail --silent --max-time 5 --location "${mavenUrl}" >/dev/null; then + return 0 + else + return 1 + fi } detect_maven_version() { - local baseDir=${1} - if [ -f ${baseDir}/system.properties ]; then - mavenVersion=$(get_app_system_value ${baseDir}/system.properties "maven.version") - if [ -n "$mavenVersion" ]; then - echo $mavenVersion - else - echo "" - fi - else - echo "" - fi + local baseDir=${1} + if [ -f ${baseDir}/system.properties ]; then + mavenVersion=$(get_app_system_value ${baseDir}/system.properties "maven.version") + if [ -n "$mavenVersion" ]; then + echo $mavenVersion + else + echo "" + fi + else + echo "" + fi } get_app_system_value() { - local file=${1?"No file specified"} - local key=${2?"No key specified"} + local file=${1?"No file specified"} + local key=${2?"No key specified"} - # escape for regex - local escaped_key=$(echo $key | sed "s/\./\\\./g") + # escape for regex + local escaped_key=$(echo $key | sed "s/\./\\\./g") - [ -f $file ] && \ - grep -E ^$escaped_key[[:space:]=]+ $file | \ - sed -E -e "s/$escaped_key([\ \t]*=[\ \t]*|[\ \t]+)([A-Za-z0-9\.-]*).*/\2/g" + [ -f $file ] && + grep -E ^$escaped_key[[:space:]=]+ $file | + sed -E -e "s/$escaped_key([\ \t]*=[\ \t]*|[\ \t]+)([A-Za-z0-9\.-]*).*/\2/g" } cache_copy() { - rel_dir=$1 - from_dir=$2 - to_dir=$3 - rm -rf "${to_dir:?}/${rel_dir:?}" - if [ -d $from_dir/$rel_dir ]; then - mkdir -p $to_dir/$rel_dir - cp -pr $from_dir/$rel_dir/. $to_dir/$rel_dir - fi + rel_dir=$1 + from_dir=$2 + to_dir=$3 + rm -rf "${to_dir:?}/${rel_dir:?}" + if [ -d $from_dir/$rel_dir ]; then + mkdir -p $to_dir/$rel_dir + cp -pr $from_dir/$rel_dir/. $to_dir/$rel_dir + fi } install_jdk() { - local install_dir=${1} - local cache_dir=${2} - - let start=$(nowms) - JVM_COMMON_BUILDPACK=${JVM_COMMON_BUILDPACK:-https://buildpack-registry.s3.us-east-1.amazonaws.com/buildpacks/heroku/jvm.tgz} - 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 - source /tmp/jvm-common/bin/util - source /tmp/jvm-common/bin/java - source /tmp/jvm-common/opt/jdbc.sh - mtime "jvm-common.install.time" "${start}" - - let start=$(nowms) - install_java_with_overlay "${install_dir}" "${cache_dir}" - mtime "jvm.install.time" "${start}" + local install_dir=${1} + local cache_dir=${2} + + let start=$(nowms) + JVM_COMMON_BUILDPACK=${JVM_COMMON_BUILDPACK:-https://buildpack-registry.s3.us-east-1.amazonaws.com/buildpacks/heroku/jvm.tgz} + 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 + source /tmp/jvm-common/bin/util + source /tmp/jvm-common/bin/java + source /tmp/jvm-common/opt/jdbc.sh + mtime "jvm-common.install.time" "${start}" + + let start=$(nowms) + install_java_with_overlay "${install_dir}" "${cache_dir}" + mtime "jvm.install.time" "${start}" } diff --git a/lib/frameworks.sh b/lib/frameworks.sh index 6d6c3783..b96189ec 100644 --- a/lib/frameworks.sh +++ b/lib/frameworks.sh @@ -1,34 +1,35 @@ #!/usr/bin/env bash is_spring_boot() { - local buildDir=${1:?} - test -f ${buildDir}/pom.xml && - test -n "$(grep "org.springframework.boot" ${buildDir}/pom.xml)" && - test -n "$(grep "spring-boot" ${buildDir}/pom.xml)" + local buildDir=${1:?} + test -f ${buildDir}/pom.xml && + test -n "$(grep "org.springframework.boot" ${buildDir}/pom.xml)" && + test -n "$(grep "spring-boot" ${buildDir}/pom.xml)" } is_wildfly_swarm() { - local buildDir=${1:?} - test -f ${buildDir}/pom.xml && - test -n "$(grep "org.wildfly.swarm" ${buildDir}/pom.xml)" + local buildDir=${1:?} + test -f ${buildDir}/pom.xml && + test -n "$(grep "org.wildfly.swarm" ${buildDir}/pom.xml)" } is_micronaut() { - local buildDir=${1:?} - test -f ${buildDir}/pom.xml && - test -n "$(grep "io.micronaut" ${buildDir}/pom.xml)" + local buildDir=${1:?} + test -f ${buildDir}/pom.xml && + test -n "$(grep "io.micronaut" ${buildDir}/pom.xml)" } is_quarkus() { - local buildDir=${1:?} - test -f ${buildDir}/pom.xml && - test -n "$(grep "io.quarkus" ${buildDir}/pom.xml)" + local buildDir=${1:?} + test -f ${buildDir}/pom.xml && + test -n "$(grep "io.quarkus" ${buildDir}/pom.xml)" } has_postgres() { - local buildDir=${1:?} - test -f ${buildDir}/pom.xml && ( - test -n "$(grep "org.postgresql" ${buildDir}/pom.xml)" || - test -n "$(grep "postgresql" ${buildDir}/pom.xml)" || - test -n "$(grep "com.impossibl.pgjdbc-ng" ${buildDir}/pom.xml)") + local buildDir=${1:?} + test -f ${buildDir}/pom.xml && ( + test -n "$(grep "org.postgresql" ${buildDir}/pom.xml)" || + test -n "$(grep "postgresql" ${buildDir}/pom.xml)" || + test -n "$(grep "com.impossibl.pgjdbc-ng" ${buildDir}/pom.xml)" + ) } diff --git a/lib/maven.sh b/lib/maven.sh index 541ca4ad..72042dc7 100644 --- a/lib/maven.sh +++ b/lib/maven.sh @@ -1,128 +1,128 @@ #!/usr/bin/env bash _mvn_java_opts() { - local scope=${1} - local home=${2} - local cache=${3} - - echo -n "-Xmx1024m" - if [ "$scope" = "compile" ]; then - echo -n " $MAVEN_JAVA_OPTS" - elif [ "$scope" = "test-compile" ]; then - echo -n "" - fi - - echo -n " -Duser.home=$home -Dmaven.repo.local=$cache/.m2/repository" + local scope=${1} + local home=${2} + local cache=${3} + + echo -n "-Xmx1024m" + if [ "$scope" = "compile" ]; then + echo -n " $MAVEN_JAVA_OPTS" + elif [ "$scope" = "test-compile" ]; then + echo -n "" + fi + + echo -n " -Duser.home=$home -Dmaven.repo.local=$cache/.m2/repository" } _mvn_cmd_opts() { - local scope=${1} - - if [ "$scope" = "compile" ]; then - echo -n "${MAVEN_CUSTOM_OPTS:-"-DskipTests"}" - echo -n " ${MAVEN_CUSTOM_GOALS:-"clean dependency:list install"}" - elif [ "$scope" = "test-compile" ]; then - echo -n "${MAVEN_CUSTOM_GOALS:-"clean dependency:resolve-plugins test-compile"}" - else - echo -n "" - fi + local scope=${1} + + if [ "$scope" = "compile" ]; then + echo -n "${MAVEN_CUSTOM_OPTS:-"-DskipTests"}" + echo -n " ${MAVEN_CUSTOM_GOALS:-"clean dependency:list install"}" + elif [ "$scope" = "test-compile" ]; then + echo -n "${MAVEN_CUSTOM_GOALS:-"clean dependency:resolve-plugins test-compile"}" + else + echo -n "" + fi } _mvn_settings_opt() { - local home="${1}" - local mavenInstallDir="${2}" - - if [ -n "$MAVEN_SETTINGS_PATH" ]; then - mcount "mvn.settings.path" - echo -n "-s $MAVEN_SETTINGS_PATH" - elif [ -n "$MAVEN_SETTINGS_URL" ]; then - local settingsXml="${mavenInstallDir}/.m2/settings.xml" - mkdir -p $(dirname ${settingsXml}) - curl --retry 3 --retry-connrefused --connect-timeout 5 --silent --max-time 10 --location $MAVEN_SETTINGS_URL --output ${settingsXml} - mcount "mvn.settings.url" - if [ -f ${settingsXml} ]; then - echo -n "-s ${settingsXml}" - else - mcount "mvn.settings.url.fail" - error "Could not download settings.xml from the URL defined in MAVEN_SETTINGS_URL!" - return 1 - fi - elif [ -f ${home}/settings.xml ]; then - mcount "mvn.settings.file" - echo -n "-s ${home}/settings.xml" - else - mcount "mvn.settings.default" - echo -n "" - fi + local home="${1}" + local mavenInstallDir="${2}" + + if [ -n "$MAVEN_SETTINGS_PATH" ]; then + mcount "mvn.settings.path" + echo -n "-s $MAVEN_SETTINGS_PATH" + elif [ -n "$MAVEN_SETTINGS_URL" ]; then + local settingsXml="${mavenInstallDir}/.m2/settings.xml" + mkdir -p $(dirname ${settingsXml}) + curl --retry 3 --retry-connrefused --connect-timeout 5 --silent --max-time 10 --location $MAVEN_SETTINGS_URL --output ${settingsXml} + mcount "mvn.settings.url" + if [ -f ${settingsXml} ]; then + echo -n "-s ${settingsXml}" + else + mcount "mvn.settings.url.fail" + error "Could not download settings.xml from the URL defined in MAVEN_SETTINGS_URL!" + return 1 + fi + elif [ -f ${home}/settings.xml ]; then + mcount "mvn.settings.file" + echo -n "-s ${home}/settings.xml" + else + mcount "mvn.settings.default" + echo -n "" + fi } has_maven_wrapper() { - local home=${1} - if [ -f $home/mvnw ] && - [ -f $home/.mvn/wrapper/maven-wrapper.properties ] && - [ -z "$(detect_maven_version $home)" ]; then - return 0; - else - return 1; - fi + local home=${1} + if [ -f $home/mvnw ] && + [ -f $home/.mvn/wrapper/maven-wrapper.properties ] && + [ -z "$(detect_maven_version $home)" ]; then + return 0 + else + return 1 + fi } get_cache_status() { - local cacheDir=${1} - if [ ! -d ${cacheDir}/.m2 ]; then - echo "not-found" - else - echo "valid" - fi + local cacheDir=${1} + if [ ! -d ${cacheDir}/.m2 ]; then + echo "not-found" + else + echo "valid" + fi } run_mvn() { - local scope=${1} - local home=${2} - local mavenInstallDir=${3} - - mkdir -p ${mavenInstallDir} - if has_maven_wrapper $home; then - cache_copy ".m2/wrapper" $mavenInstallDir $home - chmod +x $home/mvnw - local mavenExe="./mvnw" - mcount "mvn.version.wrapper" - else - cd $mavenInstallDir - let start=$(nowms) - install_maven ${mavenInstallDir} ${home} - mtime "mvn.${scope}.time" "${start}" - PATH="${mavenInstallDir}/.maven/bin:$PATH" - local mavenExe="mvn" - cd $home - fi - - local mvn_settings_opt="$(_mvn_settings_opt ${home} ${mavenInstallDir})" - - export MAVEN_OPTS="$(_mvn_java_opts ${scope} ${home} ${mavenInstallDir})" - - cd $home - local mvnOpts="$(_mvn_cmd_opts ${scope})" - status "Executing Maven" - echo "$ ${mavenExe} ${mvnOpts}" | indent - - local cache_status="$(get_cache_status ${mavenInstallDir})" - let start=$(nowms) - - if ! ${mavenExe} -DoutputFile=target/mvn-dependency-list.log -B ${mvn_settings_opt} ${mvnOpts} | indent; then - error "Failed to build app with Maven + local scope=${1} + local home=${2} + local mavenInstallDir=${3} + + mkdir -p ${mavenInstallDir} + if has_maven_wrapper $home; then + cache_copy ".m2/wrapper" $mavenInstallDir $home + chmod +x $home/mvnw + local mavenExe="./mvnw" + mcount "mvn.version.wrapper" + else + cd $mavenInstallDir + let start=$(nowms) + install_maven ${mavenInstallDir} ${home} + mtime "mvn.${scope}.time" "${start}" + PATH="${mavenInstallDir}/.maven/bin:$PATH" + local mavenExe="mvn" + cd $home + fi + + local mvn_settings_opt="$(_mvn_settings_opt ${home} ${mavenInstallDir})" + + export MAVEN_OPTS="$(_mvn_java_opts ${scope} ${home} ${mavenInstallDir})" + + cd $home + local mvnOpts="$(_mvn_cmd_opts ${scope})" + status "Executing Maven" + echo "$ ${mavenExe} ${mvnOpts}" | indent + + local cache_status="$(get_cache_status ${mavenInstallDir})" + let start=$(nowms) + + if ! ${mavenExe} -DoutputFile=target/mvn-dependency-list.log -B ${mvn_settings_opt} ${mvnOpts} | 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/" - fi + fi - mtime "mvn.${scope}.time" "${start}" - mtime "mvn.${scope}.time.cache.${cache_status}" "${start}" + mtime "mvn.${scope}.time" "${start}" + mtime "mvn.${scope}.time.cache.${cache_status}" "${start}" } write_mvn_profile() { - local home=${1} - mkdir -p ${home}/.profile.d - cat << EOF > ${home}/.profile.d/maven.sh + local home=${1} + mkdir -p ${home}/.profile.d + cat <${home}/.profile.d/maven.sh export M2_HOME="\$HOME/.maven" export MAVEN_OPTS="$(_mvn_java_opts "test" "\$HOME" "\$HOME")" export PATH="\$M2_HOME/bin:\$PATH" @@ -130,10 +130,10 @@ EOF } remove_mvn() { - local home=${1} - local mavenInstallDir=${2} - if has_maven_wrapper $home; then - cache_copy ".m2/wrapper" "$home" "$mavenInstallDir" - rm -rf "$home/.m2" - fi + local home=${1} + local mavenInstallDir=${2} + if has_maven_wrapper $home; then + cache_copy ".m2/wrapper" "$home" "$mavenInstallDir" + rm -rf "$home/.m2" + fi }