Combining tools.deps with Leiningen

I’m really liking the way tools.deps.alpha is shaping up. I’ve wanted something like this since forever: a tool that manages dependencies and the classpath, and nothing more, the way that e.g. Ruby has bundler.

But you’ll still need some kind of task runner for automating things like building jars, running tests, etc.

This could perhaps still be leiningen, but then leiningen would need to be tools.deps-aware, maybe something like

(defproject foo
  :dependencies :tools.deps
  ,,,)

Do you think we’ll get something like this, or are boot/lein just going to continue doing their own thing? I wonder how hard it would be to implement this.

Or maybe we’ll start seeing a new tool that fills this gap.

4 Likes

I think this would be a fantastic way forward especially with regards to interoperability between Boot and Leiningen. Also it should make static analysis of dependencies much much easier for tools like Cursive.

I’ve seen Sean Corfield mention that he wants to work on something like this for Boot but I don’t think there’s any code yet.

Yup. We already have all our dependencies in external EDN files st work and I’d like to switch them over to the tools.deps format so I’ll be writing this code at some point.

Nice! We’re currently doing something like this for Leiningen

;; project.clj
(require '[clojure.edn :as edn])

(def +deps+ (-> "deps.edn" slurp edn/read-string))

(defn deps->vec [deps]
  (vec (map (fn [[dep {:keys [:mvn/version exclusions]}]]
              (cond-> [dep version]
                exclusions (conj :exclusions exclusions)))
            deps)))

(def dependencies
  (deps->vec (:deps +deps+)))

(def dev-dependencies
  (deps->vec (get-in +deps+ [:aliases :dev :extra-deps])))

(def source-paths
  (vec (:paths +deps+)))

(defproject my-project "1.0.0"
  :dependencies ~dependencies
  :source-paths ~source-paths
  :profiles
  {:dev
   {:dependencies ~dev-dependencies}})
2 Likes

That doesn’t handle any of the cascading from system deps to user deps to project deps tho’ – I would want to take that into account. I’ll probably look at it this weekend, since my partner’s away (judging a cat show in Shanghai!) and I’ll be bored :slight_smile:

1 Like

#lifegoals :joy: (sorry for the noise, had to)

5 Likes

So far my weekend boredom has been consumed with enhancing how Marginalia deals with inline comments but after lunch I think I’ll tackle tools.deps :slight_smile:

1 Like

I saw @seancorfield posting this in the Boot slack: https://github.com/seancorfield/boot-tools-deps

3 Likes

This is brewing for Leiningen: “A leiningen plugin that lets you share tools.deps.alpha dependencies in your leiningen project”

4 Likes