Fork me on GitHub

Is there a way to run -P for all aliases in a deps.edn file? My use case is that we have CI build that runs steps in parallel, so we'd like to download every dep that every alias needs into the local Maven cache before running the CI steps to prevent concurrent access to ~/.m2. We could list all aliases manually, but if there's a new alias, then we need to remember to add it into the -P step.


Write a script :)


Yeah, that's one option. Was wondering whether we could leverage the tools.deps API and -X to do something like that. Will look into it.


@flowthing Getting all aliases from a deps.edn is quite easy. This is a bb script:

(require '[clojure.edn :as edn]
         '[clojure.string :as str])

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

(def aliases (keys (:aliases edn)))

(require '[babashka.deps :as deps])

(def cmd ["-P" (str "-A" (str/join aliases))])

(println "Downloading deps using:" cmd)

(deps/clojure cmd)


That looks simple enough, thanks!


Golfing a bit here, but I guess this'd also do it:

{:aliases {:foo {:extra-deps {criterium/criterium {:mvn/version "0.4.6"}}}
           :bar {:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}}}
           :baz {:extra-deps {cheshire/cheshire {:mvn/version "5.10.0"}}}}}
    '[ :as io]
    '[ :as deps]
    '[ :as mvn])
    (assoc (deps/slurp-deps (io/file "deps.edn")) :mvn/repos mvn/standard-repos)
    (deps/resolve-deps deps (deps/combine-aliases deps (->> deps :aliases keys))))