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

+4 votes
in tools.deps.alpha 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

+3 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.

...