diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cc14a0..e326adb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +* Use symlinks instead of moving the build directory. ([#278](https://github.com/heroku/heroku-buildpack-scala/pull/278)) ## [v103] - 2025-10-27 diff --git a/bin/compile b/bin/compile index 1162580..7f91a48 100755 --- a/bin/compile +++ b/bin/compile @@ -34,22 +34,11 @@ metrics::setup if is_app_dir "${APP_BUILD_DIR}"; then BUILD_DIR="/tmp/scala_buildpack_build_dir" - mv "${APP_BUILD_DIR}" "${BUILD_DIR}" + ln -s "${APP_BUILD_DIR}" "${BUILD_DIR}" else BUILD_DIR="${APP_BUILD_DIR}" fi -# When multiple buildpacks are used, earlier buildpacks may add executables to PATH -# and GEM_PATH that reference APP_BUILD_DIR. Since we've moved the build directory to -# a temp location, we must rewrite these environment variables to replace APP_BUILD_DIR -# with the new BUILD_DIR so that executables added by earlier buildpacks remain accessible. -PATH=${PATH//"${APP_BUILD_DIR}"/"${BUILD_DIR}"} -export PATH -if [[ -n "${GEM_PATH:-}" ]]; then - GEM_PATH=${GEM_PATH//"${APP_BUILD_DIR}"/"${BUILD_DIR}"} - export GEM_PATH -fi - util::export_env_dir "${ENV_DIR}" "." "JAVA_OPTS" # Used by openjdk::install_openjdk_via_jvm_common_buildpack to determine which JVM common buildpack to use @@ -277,11 +266,6 @@ cat <<-EOF >"${profile_script}" export PATH="\$SBT_HOME/bin:\$PATH" EOF -# Move compiled app back to where Heroku expects it -if is_app_dir "${APP_BUILD_DIR}"; then - mv "${BUILD_DIR}" "${APP_BUILD_DIR}" -fi - # write export script cat <<-EOF >"${BASE_DIR}/export" export SBT_HOME="${APP_BUILD_DIR}/${SBT_USER_HOME}" diff --git a/test/spec/cache_spec.rb b/test/spec/cache_spec.rb index ea51209..109f0b6 100644 --- a/test/spec/cache_spec.rb +++ b/test/spec/cache_spec.rb @@ -13,21 +13,21 @@ remote: -----> Running: sbt compile stage remote: Downloading sbt launcher for 1.11.7: remote: From https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.11.7/sbt-launch-1.11.7.jar - remote: To /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.11.7/sbt-launch.jar + remote: To /tmp/[^/]+/.sbt_home/launchers/1.11.7/sbt-launch.jar remote: Downloading sbt launcher 1.11.7 md5 hash: remote: From https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.11.7/sbt-launch-1.11.7.jar.md5 - remote: To /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.11.7/sbt-launch.jar.md5 - remote: /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.11.7/sbt-launch.jar: OK + remote: To /tmp/[^/]+/.sbt_home/launchers/1.11.7/sbt-launch.jar.md5 + remote: /tmp/[^/]+/.sbt_home/launchers/1.11.7/sbt-launch.jar: OK remote: \\[info\\] \\[launcher\\] getting org.scala-sbt sbt 1.11.7 \\(this may take some time\\)... remote: \\[info\\] \\[launcher\\] getting Scala 2.12.20 \\(for sbt\\)... remote: \\[info\\] welcome to sbt 1.11.7 \\(Azul Systems, Inc. Java 21.0.[0-9]+\\) - remote: \\[info\\] loading global plugins from /tmp/scala_buildpack_build_dir/.sbt_home/plugins - remote: \\[info\\] compiling 1 Scala source to /tmp/scala_buildpack_build_dir/.sbt_home/plugins/target/scala-2.12/sbt-1.0/classes ... + remote: \\[info\\] loading global plugins from /tmp/[^/]+/.sbt_home/plugins + remote: \\[info\\] compiling 1 Scala source to /tmp/[^/]+/.sbt_home/plugins/target/scala-2.12/sbt-1.0/classes ... remote: \\[info\\] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.20. Compiling... remote: \\[info\\] Compilation completed in .*s. remote: \\[info\\] done compiling - remote: \\[info\\] loading settings for project scala_buildpack_build_dir-build from plugins.sbt... - remote: \\[info\\] loading project definition from /tmp/scala_buildpack_build_dir/project + remote: \\[info\\] loading settings for project [^\\s]+-build from plugins.sbt... + remote: \\[info\\] loading project definition from /tmp/[^/]+/project remote: \\[info\\] loading settings for project root from build.sbt... remote: \\[info\\] __ __ remote: \\[info\\] \\\\ \\\\ ____ / /____ _ __ __ @@ -42,10 +42,10 @@ remote: \\[info\\] https://www.playframework.com/sponsors remote: \\[info\\] remote: \\[info\\] Executing in batch mode. For better performance use sbt's shell - remote: \\[info\\] compiling 7 Scala sources and 1 Java source to /tmp/scala_buildpack_build_dir/target/scala-2.13/classes ... + remote: \\[info\\] compiling 7 Scala sources and 1 Java source to /tmp/[^/]+/target/scala-2.13/classes ... remote: \\[info\\] done compiling remote: \\[success\\] Total time: .* s, completed .* - remote: \\[info\\] Wrote /tmp/scala_buildpack_build_dir/target/scala-2.13/sbt-0-11-7-play-3-x-scala-2-13-x_2.13-1.0-SNAPSHOT.pom + remote: \\[info\\] Wrote /tmp/[^/]+/target/scala-2.13/sbt-0-11-7-play-3-x-scala-2-13-x_2.13-1.0-SNAPSHOT.pom remote: \\[success\\] Total time: .* remote: -----> Collecting dependency information remote: -----> Dropping ivy cache from the slug @@ -68,9 +68,9 @@ remote: -----> Installing Azul Zulu OpenJDK 21.0.[0-9]+ remote: -----> Running: sbt compile stage remote: \\[info\\] welcome to sbt 1.11.7 \\(Azul Systems, Inc. Java 21.0.[0-9]+\\) - remote: \\[info\\] loading global plugins from /tmp/scala_buildpack_build_dir/.sbt_home/plugins - remote: \\[info\\] loading settings for project scala_buildpack_build_dir-build from plugins.sbt... - remote: \\[info\\] loading project definition from /tmp/scala_buildpack_build_dir/project + remote: \\[info\\] loading global plugins from /tmp/[^/]+/.sbt_home/plugins + remote: \\[info\\] loading settings for project [^\\s]+-build from plugins.sbt... + remote: \\[info\\] loading project definition from /tmp/[^/]+/project remote: \\[info\\] loading settings for project root from build.sbt... remote: \\[info\\] __ __ remote: \\[info\\] \\\\ \\\\ ____ / /____ _ __ __ @@ -86,7 +86,7 @@ remote: \\[info\\] remote: \\[info\\] Executing in batch mode. For better performance use sbt's shell remote: \\[success\\] Total time: .* s, completed .* - remote: \\[info\\] Wrote /tmp/scala_buildpack_build_dir/target/scala-2.13/sbt-0-11-7-play-3-x-scala-2-13-x_2.13-1.0-SNAPSHOT.pom + remote: \\[info\\] Wrote /tmp/[^/]+/target/scala-2.13/sbt-0-11-7-play-3-x-scala-2-13-x_2.13-1.0-SNAPSHOT.pom remote: \\[success\\] Total time: .* remote: -----> Collecting dependency information remote: -----> Dropping ivy cache from the slug @@ -131,7 +131,7 @@ remote: -----> Running: sbt compile stage remote: Downloading sbt launcher for 0.13.9: remote: From https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.9/sbt-launch.jar - remote: To /tmp/scala_buildpack_build_dir/.sbt_home/launchers/0.13.9/sbt-launch.jar + remote: To /tmp/[^\\s]+/.sbt_home/launchers/0.13.9/sbt-launch.jar remote: remote: Getting org.scala-sbt sbt 0.13.9 ... remote: downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.9/jars/sbt.jar ... @@ -253,8 +253,8 @@ remote: :: retrieving :: org.scala-sbt#boot-scala remote: confs: \\[default\\] remote: 5 artifacts copied, 0 already retrieved \\(24493kB/[0-9]+ms\\) - remote: \\[info\\] Loading global plugins from /tmp/scala_buildpack_build_dir/.sbt_home/plugins - remote: \\[info\\] Updating \\{file:/tmp/scala_buildpack_build_dir/.sbt_home/plugins/\\}global-plugins... + remote: \\[info\\] Loading global plugins from /tmp/[^\\s]+/.sbt_home/plugins + remote: \\[info\\] Updating \\{file:/tmp/[^\\s]+/.sbt_home/plugins/\\}global-plugins... remote: \\[info\\] Resolving org.scala-lang#scala-library;2.10.5 ... remote: \\[info\\] Resolving org.scala-sbt#sbt;0.13.9 ... remote: \\[info\\] Resolving org.scala-sbt#main;0.13.9 ... @@ -311,9 +311,9 @@ remote: \\[info\\] Resolving org.scala-lang#jline;2.10.5 ... remote: \\[info\\] Resolving org.fusesource.jansi#jansi;1.4 ... remote: \\[info\\] Done updating. - remote: \\[info\\] Compiling 1 Scala source to /tmp/scala_buildpack_build_dir/.sbt_home/plugins/target/scala-2.10/sbt-0.13/classes... - remote: \\[info\\] Loading project definition from /tmp/scala_buildpack_build_dir/project - remote: \\[info\\] Updating \\{file:/tmp/scala_buildpack_build_dir/project/\\}scala_buildpack_build_dir-build... + remote: \\[info\\] Compiling 1 Scala source to /tmp/[^\\s]+/.sbt_home/plugins/target/scala-2.10/sbt-0.13/classes... + remote: \\[info\\] Loading project definition from /tmp/[^\\s]+/project + remote: \\[info\\] Updating \\{file:/tmp/[^\\s]+/project/\\}[^\\s]+-build... remote: \\[info\\] Resolving org.scala-sbt#global-plugins;0.0 ... remote: \\[info\\] Resolving com.typesafe.play#sbt-plugin;2.4.2 ... remote: \\[info\\] Resolving com.typesafe.play#sbt-plugin;2.4.2 ... @@ -833,8 +833,8 @@ remote: \\[info\\] downloading https://jcenter.bintray.com/org/webjars/npm/2.11.2/npm-2.11.2.jar ... remote: \\[info\\] \\[SUCCESSFUL \\] org.webjars#npm;2.11.2!npm.jar \\([0-9]+ms\\) remote: \\[info\\] Done updating. - remote: \\[info\\] Set current project to play-2.4.x-scala \\(in build file:/tmp/scala_buildpack_build_dir/\\) - remote: \\[info\\] Updating \\{file:/tmp/scala_buildpack_build_dir/\\}root... + remote: \\[info\\] Set current project to play-2.4.x-scala \\(in build file:/tmp/[^\\s]+/\\) + remote: \\[info\\] Updating \\{file:/tmp/[^\\s]+/\\}root... remote: \\[info\\] Resolving org.scala-lang#scala-compiler;2.11.6 ... remote: \\[info\\] Resolving org.scala-lang#scala-compiler;2.11.6 ... remote: \\[info\\] Resolving org.scala-lang#scala-library;2.11.6 ... @@ -1359,16 +1359,16 @@ remote: \\[info\\] downloading https://jcenter.bintray.com/jline/jline/2.12.1/jline-2.12.1.jar ... remote: \\[info\\] \\[SUCCESSFUL \\] jline#jline;2.12.1!jline.jar \\([0-9]+ms\\) remote: \\[info\\] Done updating. - remote: \\[info\\] Compiling 7 Scala sources and 1 Java source to /tmp/scala_buildpack_build_dir/target/scala-2.11/classes... + remote: \\[info\\] Compiling 7 Scala sources and 1 Java source to /tmp/[^\\s]+/target/scala-2.11/classes... remote: \\[info\\] 'compiler-interface' not yet compiled for Scala 2.11.6. Compiling... remote: \\[info\\] Compilation completed in .* remote: \\[success\\] Total time: .*, completed .* - remote: \\[info\\] Wrote /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.pom - remote: \\[info\\] Packaging /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-web-assets.jar ... - remote: \\[info\\] Packaging /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.jar ... + remote: \\[info\\] Wrote /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.pom + remote: \\[info\\] Packaging /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-web-assets.jar ... + remote: \\[info\\] Packaging /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.jar ... remote: \\[info\\] Done packaging. remote: \\[info\\] Done packaging. - remote: \\[info\\] Packaging /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-sans-externalized.jar ... + remote: \\[info\\] Packaging /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-sans-externalized.jar ... remote: \\[info\\] Done packaging. remote: \\[success\\] Total time: .*, completed .* remote: -----> Collecting dependency information @@ -1408,8 +1408,8 @@ remote: ! - https://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html remote: remote: -----> Running: sbt compile stage - remote: \\[info\\] Loading global plugins from /tmp/scala_buildpack_build_dir/.sbt_home/plugins - remote: \\[info\\] Updating \\{file:/tmp/scala_buildpack_build_dir/.sbt_home/plugins/\\}global-plugins... + remote: \\[info\\] Loading global plugins from /tmp/[^\\s]+/.sbt_home/plugins + remote: \\[info\\] Updating \\{file:/tmp/[^\\s]+/.sbt_home/plugins/\\}global-plugins... remote: \\[info\\] Resolving org.scala-lang#scala-library;2.10.5 ... remote: \\[info\\] Resolving org.scala-sbt#sbt;0.13.9 ... remote: \\[info\\] Resolving org.scala-sbt#main;0.13.9 ... @@ -1466,9 +1466,9 @@ remote: \\[info\\] Resolving org.scala-lang#jline;2.10.5 ... remote: \\[info\\] Resolving org.fusesource.jansi#jansi;1.4 ... remote: \\[info\\] Done updating. - remote: \\[info\\] Compiling 1 Scala source to /tmp/scala_buildpack_build_dir/.sbt_home/plugins/target/scala-2.10/sbt-0.13/classes... - remote: \\[info\\] Loading project definition from /tmp/scala_buildpack_build_dir/project - remote: \\[info\\] Updating \\{file:/tmp/scala_buildpack_build_dir/project/\\}scala_buildpack_build_dir-build... + remote: \\[info\\] Compiling 1 Scala source to /tmp/[^\\s]+/.sbt_home/plugins/target/scala-2.10/sbt-0.13/classes... + remote: \\[info\\] Loading project definition from /tmp/[^\\s]+/project + remote: \\[info\\] Updating \\{file:/tmp/[^\\s]+/project/\\}[^\\s]+-build... remote: \\[info\\] Resolving org.scala-sbt#global-plugins;0.0 ... remote: \\[info\\] Resolving com.typesafe.play#sbt-plugin;2.4.2 ... remote: \\[info\\] Resolving com.typesafe.play#routes-compiler_2.10;2.4.2 ... @@ -1615,8 +1615,8 @@ remote: \\[info\\] Resolving org.scala-lang#jline;2.10.5 ... remote: \\[info\\] Resolving org.fusesource.jansi#jansi;1.4 ... remote: \\[info\\] Done updating. - remote: \\[info\\] Set current project to play-2.4.x-scala \\(in build file:/tmp/scala_buildpack_build_dir/\\) - remote: \\[info\\] Updating {file:/tmp/scala_buildpack_build_dir/}root... + remote: \\[info\\] Set current project to play-2.4.x-scala \\(in build file:/tmp/[^\\s]+/\\) + remote: \\[info\\] Updating {file:/tmp/[^\\s]+/}root... remote: \\[info\\] Resolving org.scala-lang#scala-compiler;2.11.6 ... remote: \\[info\\] Resolving org.scala-lang#scala-library;2.11.6 ... remote: \\[info\\] Resolving org.scala-lang#scala-reflect;2.11.6 ... @@ -1731,14 +1731,14 @@ remote: \\[info\\] Resolving org.ow2.asm#asm-util;4.1 ... remote: \\[info\\] Resolving jline#jline;2.12.1 ... remote: \\[info\\] Done updating. - remote: \\[info\\] Compiling 7 Scala sources and 1 Java source to /tmp/scala_buildpack_build_dir/target/scala-2.11/classes... + remote: \\[info\\] Compiling 7 Scala sources and 1 Java source to /tmp/[^\\s]+/target/scala-2.11/classes... remote: \\[success\\] Total time: .*, completed .* - remote: \\[info\\] Wrote /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.pom - remote: \\[info\\] Packaging /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-web-assets.jar ... - remote: \\[info\\] Packaging /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.jar ... + remote: \\[info\\] Wrote /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.pom + remote: \\[info\\] Packaging /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-web-assets.jar ... + remote: \\[info\\] Packaging /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT.jar ... remote: \\[info\\] Done packaging. remote: \\[info\\] Done packaging. - remote: \\[info\\] Packaging /tmp/scala_buildpack_build_dir/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-sans-externalized.jar ... + remote: \\[info\\] Packaging /tmp/[^\\s]+/target/scala-2.11/play-2-4-x-scala_2.11-1.0-SNAPSHOT-sans-externalized.jar ... remote: \\[info\\] Done packaging. remote: \\[success\\] Total time: .*, completed .* remote: -----> Collecting dependency information