Welcome! Please see the About page for a little more info on how this works.

+8 votes
in tools.deps by

Leiningen has a feature called Managed Dependencies. This lets you set a common version for a transitive dependency to be used instead of relying on versions provided by your dependencies. This is useful when you want to specify a version of a library without actually adding a dependency on it. It has a very similar effect (I think) as adding the dependency directly to your Leiningen :dependencies, but communicates the intention better.

Is there something similar like this in deps.edn? A way to specify a version resolution for a dependency without adding it directly to :deps?

2 Answers

+4 votes
by

At work we rely heavily on :override-deps in a project-wide deps.edn file (we use CLJ_CONFIG to pick up that instead of the user-level deps.edn file). We have an alias called :defaults that has :override-deps with an entry for everything dependency that we want to "manage".

Our (mono-)repo has a versions folder containing that project-wide file and then each subproject in the repo has its own deps.edn file where we specify dependencies like this:

selmer {} ; omit :mvn/version "x.y.z"

And versions/deps.edn has:

:aliases
{:defaults
 {:override-deps
  {selmer {:mvn/version "1.12.13"}
   ...}}}

Then we do this inside a subproject:

CLJ_CONFIG=../versions clojure -A:defaults <whatever else we need>
+1 vote
by

The similar use case in deps is :default-deps which allows you to set the default deps to use when the version is undefined. However, we have never actually specified how to include a dep without a version such that the default will get picked up.

Also, we probably need more flexibility in specifying a base deps.edn which could be a place to state those default deps.

So, it’s still a work in progress.

by
Hi @alexmiller,
I like :default-deps!
What's the best way to pull it in?

What I'd like is root directory containing blessed-versions.edn or similar,
and then sub directories with a deps.edn that has "nil" as the version, and pulls in the "blessed version"... is that achievable without using CLJ_CONFIG (which conflicts with user configuration)?
by
Currently, no I don’t think so.
by
Did we specify "how to include a dep without a version such that the default will get picked up" yet? @alexmiller
by
No update, but I think https://ask.clojure.org/index.php/9849/teams-common-dependencies-tooling-across-multiple-projects is probably the place to vote/watch for updates on this.
...