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

Commit

Permalink
Cache clojure dependencies
Browse files Browse the repository at this point in the history
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.

Fixes #485.

[clojure-cli]: https://clojure.org/reference/deps_and_cli
  • Loading branch information
mainej committed Aug 26, 2022
1 parent 0f09b1e commit 6b09a45
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion run-build-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand All @@ -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"
Expand Down Expand Up @@ -934,4 +944,3 @@ install_go() {
fi

}

0 comments on commit 6b09a45

Please sign in to comment.