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

feat(caching): Cache clojure dependencies #831

Open
wants to merge 2 commits into
base: focal
Choose a base branch
from

Conversation

mainej
Copy link

@mainej mainej commented Aug 26, 2022

Summary

Fixes #485.

Projects that contain a deps.edn file are compiled by the Clojure CLI. (This is analogous to a Gemfile, which signals that a project is built with ruby.)

This PR speeds up builds of these projects by caching their dependencies. The following directories are now cached:

  • .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 saves 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.

For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update the included software doc (if you updated included software) 📄
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

@mainej mainej requested a review from a team August 26, 2022 02:50
Fixes netlify#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
@mainej mainej force-pushed the cache-clojure-focal branch from 6b09a45 to 8c569dc Compare August 26, 2022 02:52
@mainej mainej changed the title Cache clojure dependencies fix: Cache clojure dependencies Aug 26, 2022
@mainej mainej changed the title fix: Cache clojure dependencies feat(caching): Cache clojure dependencies Aug 26, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache dependencies for clojure projects using Tools.deps.alpha in addition to Leiningen and boot
2 participants