tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2021-01-13T01:17:05.312200Z

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).

alexmiller 2021-01-13T01:21:38.313100Z

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

alexmiller 2021-01-13T01:22:00.313400Z

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

alexmiller 2021-01-13T01:22:43.313800Z

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

2021-01-13T01:28:27.315200Z

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?“.

2021-01-13T01:29:18.315700Z

https://github.com/hagmonk/find-deps also adds some nice ergonomics.

2021-01-13T01:31:26.317200Z

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

alexmiller 2021-01-13T01:33:48.318200Z

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

2021-01-13T01:34:22.318700Z

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

alexmiller 2021-01-13T01:36:42.320Z

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

alexmiller 2021-01-13T01:36:58.320400Z

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

alexmiller 2021-01-13T01:38:05.320800Z

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