Skip to content
Open
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 @@ -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

Expand Down
17 changes: 3 additions & 14 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,11 @@ metrics::setup

if is_app_dir "${APP_BUILD_DIR}"; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for another PR) The function is called is_app_dir but it actually seems to checks for whether the directory is not the /app dir?

Copy link
Member

@edmorley edmorley Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a Heroku CI Hatchet test in this repo - and Heroku CI is one of the cases where the /app directory gets used instead of /tmp/build_* - would it be worth adding a Heroku CI test?

(The other case when the app dir varies is when the build-in-app-dir labs is enabled - I don't bother having a hatchet test for that for Python, but do make sure to test that labs manually when making any /app vs /tmp path-specific changes)

BUILD_DIR="/tmp/scala_buildpack_build_dir"
mv "${APP_BUILD_DIR}" "${BUILD_DIR}"
ln -s "${APP_BUILD_DIR}" "${BUILD_DIR}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(optional) I find these variable names confusing, given in most other buildpacks the BUILD_DIR really does mean the actual build dir. For example the rm "${BUILD_DIR}" later looks really bad until you know it's only the symlink!

I wonder if the symlink path should be named something else?

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
Expand Down Expand Up @@ -277,9 +266,9 @@ cat <<-EOF >"${profile_script}"
export PATH="\$SBT_HOME/bin:\$PATH"
EOF

# Move compiled app back to where Heroku expects it
# Remove symlink if we created one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(background only) For Python and PHP we don't remove the symlinks after, in case later buildpacks happen to call those paths. I imagine that's less likely to happen for Scala though.

if is_app_dir "${APP_BUILD_DIR}"; then
mv "${BUILD_DIR}" "${APP_BUILD_DIR}"
rm "${BUILD_DIR}"
fi

# write export script
Expand Down
76 changes: 38 additions & 38 deletions test/spec/cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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\\] \\\\ \\\\ ____ / /____ _ __ __
Expand All @@ -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
Expand All @@ -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\\] \\\\ \\\\ ____ / /____ _ __ __
Expand All @@ -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
Expand Down Expand Up @@ -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 ...
Expand Down Expand Up @@ -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 ...
Expand Down Expand Up @@ -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 ...
Expand Down Expand Up @@ -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 ...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ...
Expand Down Expand Up @@ -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 ...
Expand Down Expand Up @@ -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 ...
Expand Down Expand Up @@ -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
Expand Down