Fork me on GitHub
#tools-deps
<
2021-01-13
>
deactivateduser01:01:05

Not sure if this is the correct channel, but following on from a discussion during @seancorfield’s talk today for the London Clojurians, I whipped up a prototype that will determine the namespaces for one or more tools.deps dependencies. Example usage:

(namespaces-for-deps! {'http-kit/http-kit {:mvn/version "2.5.0"}
                       'ring/ring         {:mvn/version "1.8.2"}})

==> {http-kit/http-kit {:mvn/version "2.5.0", #snip#, :nses [org.httpkit.timer org.httpkit.client org.httpkit.encode org.httpkit.server org.httpkit.sni-client]}, ring/ring {:mvn/version "1.8.2", #snip#, :nses []}}
Code is here: https://gist.github.com/pmonks/982ce90dac11a4cefe45378c0db3d555 - feedback welcome, especially regarding whether this is worth turning into something else (CLI app, tools.deps plugin, wotnot).

Alex Miller (Clojure team)01:01:38

I actually have an impl of a couple things like this related to add-libs (buried in the add-libs3 branch atm)

Alex Miller (Clojure team)01:01:00

well I did, can't remember where that branch is at now

Alex Miller (Clojure team)01:01:43

I mean, it's trivial to do with combo of tools.deps/tools.namespace

deactivateduser01:01:27

Yep, and that’s all this code does. Definitely seems useful enough to want to surface - it was one of the few “holes” in Sean’s demo flow in today’s talk - “how do you determine the namespaces in a dependency at the REPL?“.

deactivateduser01:01:26

FWIW I used tda’s resolve-deps fn to pull down the requested dependencies, but that felt a bit heavyweight since it brings down the transitive graph of dependencies as well (which I don’t think tools.namespace needs to do its thing). Though I guess short-cutting the graph might cause problems with other tda-based tooling...

Alex Miller (Clojure team)01:01:48

yeah, you can pretty easily use tools.deps to pull just a single lib - it's not exactly part of the main api but you can do it

deactivateduser01:01:22

Yeah cool - not a big problem to pull down the entire graph for this kind of “exploration time” logic, imvho.

Alex Miller (Clojure team)01:01:42

it's really just crafting a call to (c.t.d.a.extensions/coord-paths 'the/lib {:mvn/version "1.2.3"} deps-edn)

Alex Miller (Clojure team)01:01:58

which should download and return a vector with one path which is the jar

Alex Miller (Clojure team)01:01:05

you do need to require c.t.d.a just to cause the multimethod extensions to all get loaded