From 8c569dcf50b46b2988d443963df3cd3bd4bf5d0e Mon Sep 17 00:00:00 2001 From: Jacob Maine Date: Wed, 28 Apr 2021 17:19:28 -0700 Subject: [PATCH] fix: Cache clojure dependencies Fixes #485. This speeds up builds that use the [Clojure CLI][clojure-cli] by avoiding network calls to download dependencies. When a repo has a `deps.edn` file, we assume it is a Clojure repo. We cache its dependencies by caching the following files: * `.m2` As a JVM language, most Clojure dependencies are stored in the global `.m2` directory. * `.gitlibs` The Clojure CLI can also download dependencies directly from git repositories rather than from a package manager. It caches these downloads in the `.gitlibs` directory. * `.cpcache` Clojure uses the `.cpcache` directory to avoid unnecessarily re-calculating the JVM classpath. Caching this directory won't prevent downloads, but does improve build time slightly. [clojure-cli]: https://clojure.org/reference/deps_and_cli --- run-build-functions.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/run-build-functions.sh b/run-build-functions.sh index 204a42cb..0bba7445 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -612,6 +612,14 @@ install_dependencies() { fi fi + # Clojure CLI + if [ -f deps.edn ] + then + restore_home_cache ".m2" "maven dependencies" + restore_home_cache ".gitlibs" "clojure git dependencies" + restore_cwd_cache ".cpcache" "clojure classpath" + fi + # Hugo if [ -n "$HUGO_VERSION" ] then @@ -699,6 +707,7 @@ cache_artifacts() { cache_cwd_directory ".venv" "python virtualenv" cache_cwd_directory ".build" "swift build" + cache_cwd_directory ".cpcache" "clojure classpath" cache_cwd_directory ".netlify/plugins" "build plugins" cache_cwd_directory ".netlify/rust-functions-cache" "Rust functions" @@ -713,6 +722,7 @@ cache_artifacts() { cache_home_directory ".emacs.d" "emacs cache" cache_home_directory ".m2" "maven dependencies" cache_home_directory ".boot" "boot dependencies" + cache_home_directory ".gitlibs" "clojure git dependencies" cache_home_directory ".composer" "composer dependencies" cache_home_directory ".homebrew-cache", "homebrew cache" cache_home_directory ".rustup" "rust rustup cache" @@ -934,4 +944,3 @@ install_go() { fi } -