Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit b6fc69b

Browse files
committed
Cache Clojure classpath and prefill caches
For repos that are built with the [Clojure CLI tools][clojure-cli] (i.e., repos marked with a `deps.edn` file), we cache and restore the `.cpcache` directory. Clojure uses this directory to avoid unnecessarily re-calculating the JVM classpath. For most projects this additional cache will not lead to a large improvement in build times. We also download dependencies to the `.m2` cache before handing off to the build script. Technically, this is unnecessary since, presumably, the build script uses the Clojure CLI tools which have a side-effect of populating `.m2`. Therefore, the benefit of this change is simply to separate the two steps, isolating any errors that occure while fetching dependencies. [clojure-cli]: https://clojure.org/reference/deps_and_cli
1 parent 5acadf8 commit b6fc69b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ RUN mkdir /opt/boot-clj && cd /opt/boot-clj && \
376376
chmod +x boot && \
377377
ln -s /opt/boot-clj/boot /usr/local/bin/boot
378378

379+
# TODO: When upgrading to >= 1.10.1.672, also update approach for populating .m2 with clojure deps:
380+
# In run-build-functions.sh replace `clojure -Spath -Sforce >/dev/null` with more modern `clojure -P`
379381
RUN curl -sL https://download.clojure.org/install/linux-install-1.10.1.492.sh | bash
380382

381383
USER buildbot

run-build-functions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,15 @@ install_dependencies() {
591591
if [ -f deps.edn ]
592592
then
593593
restore_home_cache ".m2" "maven dependencies"
594+
restore_cwd_cache ".cpcache" "clojure classpath"
595+
echo "Installing Clojure dependencies"
596+
if clojure -Spath -Sforce >/dev/null
597+
then
598+
echo "Clojure dependencies installed"
599+
else
600+
echo "Error during Clojure install"
601+
exit 1
602+
fi
594603
fi
595604

596605
# Hugo
@@ -724,6 +733,7 @@ cache_artifacts() {
724733

725734
cache_cwd_directory ".venv" "python virtualenv"
726735
cache_cwd_directory ".build" "swift build"
736+
cache_cwd_directory ".cpcache" "clojure classpath"
727737
cache_cwd_directory ".netlify/plugins" "build plugins"
728738

729739
if [ -f Cargo.toml ] || [ -f Cargo.lock ]

0 commit comments

Comments
 (0)