tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
alexmiller 2020-12-07T00:16:59.266100Z

It is intentionally not yet documented

alexmiller 2020-12-07T00:17:11.266700Z

As we are probably going to add some api around it

seancorfield 2020-12-07T00:26:31.268300Z

I think one thing that would be really helpful would be if Cognitect could at least document a minimal, standard way to use t.d.a to get the project basis -- that's not entirely clear just from the API docs.

alexmiller 2020-12-07T00:26:54.268800Z

Yeah, I have been thinking about just that

alexmiller 2020-12-07T00:27:22.269900Z

Having just done it yet again for tree stuff :)

seancorfield 2020-12-07T00:27:32.270200Z

I think it's this code, but I'm not certain:

user=> (require '[clojure.tools.deps.alpha :as t])
nil
user=> (keys (t/find-edn-maps))
(:root-edn :user-edn :project-edn)
;; -Srepro would omit user-edn here:
user=> (def deps (t/merge-edns (let [{:keys [root-edn user-edn project-edn]} (t/find-edn-maps)] [root-edn user-edn project-edn])))
#'user/deps
;; if you want to apply aliases at the tool level:
user=> (def combined (t/combine-aliases deps [:test :runner]))
#'user/combined
user=> (keys combined)
(:extra-paths :extra-deps :main-opts)
user=> combined
{:extra-paths ["src/test/clojure"], :extra-deps {org.clojure/test.check #:mvn{:version "1.0.0"}, com.cognitect/test-runner {:git/url "<https://github.com/cognitect-labs/test-runner>", :sha "f7ef16dc3b8332b0d77bc0274578ad5270fbfedd"}}, :main-opts ["-m" "cognitect.test-runner" "-d" "src/test/clojure"]}
user=&gt; (def basis (t/calc-basis deps {:resolve-args combined :classpath-args combined}))
#'user/basis

alexmiller 2020-12-07T00:28:07.270900Z

The thing is you don’t necessarily want to do all of those steps

alexmiller 2020-12-07T00:28:32.271700Z

It’s in parts so you can choose which ones to do

seancorfield 2020-12-07T00:28:41.272200Z

Yeah, if you don't need to apply aliases, you can omit the combined piece and pass an empty map to calc-basis?

alexmiller 2020-12-07T00:28:46.272500Z

And modify in between if needed

seancorfield 2020-12-07T00:29:05.272900Z

(I'm cheating a bit with passing combined as both :resolve-args and :classpath-args there)

2020-12-07T00:32:14.273100Z

I’ve been super impressed with antq too. Big 👍 from me!

alexmiller 2020-12-07T02:58:06.273600Z

Prerelease of Clojure tools 1.10.1.749 • New option for `-X:deps tree`  - `:format :edn` to print the tree as edn data • Updated `-Stree` to also use the new format

dominicm 2020-12-07T08:05:44.275800Z

Benefit of system property over depending on tda is that I can make deps.edn optional AND I don't need to bloat the classpath. I read the basis to locate output directories which tools namespace doesn't handle well.

borkdude 2020-12-07T08:39:34.276500Z

I would prefer not to depend on tools.deps in clojure itself, but a decoupled system that can represent properties in EDN from whatever tool likes to put that in at startup. Comparable to System properties, but real data. E.g.: https://clojurians.slack.com/archives/C6QH853H8/p1607297023257300

borkdude 2020-12-07T08:43:12.277600Z

Similarly spec could have been made optional with some more general hook system in the compiler for checking macros, possibly.

alexmiller 2020-12-07T13:45:03.277900Z

certainly we'll not make clojure depend on tools.deps

alexmiller 2020-12-07T13:46:16.279100Z

there is a basis api in the add-lib3 branch - some of that may move into either a very skinny lib or clojure itself tbd (that part would have no additional deps)

alexmiller 2020-12-07T13:47:32.279600Z

is the *properties* idea above about :aliases or more generic?

alexmiller 2020-12-07T13:59:25.279900Z

if not coming from :aliases, where do you imagine it's coming from?

borkdude 2020-12-07T14:51:23.280100Z

> certainly we'll not make clojure depend on tools.deps <3 <3

borkdude 2020-12-07T14:54:12.282600Z

About *properties*, I was thinking of a general way to set key/vals in a Clojure runtime, without having to deal with strings only (like in System/properties). This way you can avoid introducing more dynamic vars.

borkdude 2020-12-07T14:55:02.283100Z

e.g. *command-line-args* could just be a key in that thing, and so could *clojure-version*

borkdude 2020-12-07T14:55:19.283400Z

and perhaps :clojure-basis or :clojure/basis

borkdude 2020-12-07T14:59:03.284300Z

And one could perhaps set them from the command line with -J-Dclojure.property.clojure/basis={:a 1} so (= {:a 1} (:clojure/basis *properties*))

alexmiller 2020-12-07T15:00:55.284800Z

I think you are glossing over potentially important details, but I'll keep it in mind

dominicm 2020-12-07T17:43:38.285800Z

One benefit of a dynamic var would be binding it for different class loaders.