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

Commit 4af837c

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 87dd246 commit 4af837c

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
@@ -588,6 +588,15 @@ install_dependencies() {
588588
if [ -f deps.edn ]
589589
then
590590
restore_home_cache ".m2" "maven dependencies"
591+
restore_cwd_cache ".cpcache" "clojure classpath"
592+
echo "Installing Clojure dependencies"
593+
if clojure -Spath -Sforce >/dev/null
594+
then
595+
echo "Clojure dependencies installed"
596+
else
597+
echo "Error during Clojure install"
598+
exit 1
599+
fi
591600
fi
592601

593602
# Hugo
@@ -708,6 +717,7 @@ cache_artifacts() {
708717

709718
cache_cwd_directory ".venv" "python virtualenv"
710719
cache_cwd_directory ".build" "swift build"
720+
cache_cwd_directory ".cpcache" "clojure classpath"
711721
cache_cwd_directory ".netlify/plugins" "build plugins"
712722

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

0 commit comments

Comments
 (0)