Is it possible to add a dependency from the command line and invoke -X with an alias at the same time? I have the following invocation (generalized):
clojure -Sdeps '{:deps {com.github.markbastian/myproject
{:git/url ""
:sha "SOMEGITSHA"}}}' \
-X:myalias myproject.main/run
When I run the command, I get the message: WARNING: Specified aliases are undeclared and are not being used: [:myalias]. How might I do this? I can invoke clj -X:myalias myproject.main/run from within the project just fine. The alias is definitely in the deps edn associated with the sha of the commit.i think because you are clobbering the deps.
❯ cat deps.edn
{:deps {}
:aliases
{:demo {:exec-fn clojure.core/println}}}
❯ clj -Sdeps '{:aliases {:crit {:extra-deps {criterium/criterium {:mvn/version "LATEST"}}}}}' -X:crit:demo :a 1
{:a 1}put the extra stuff in an alias
actually, it seems fine in your original case for me:
# a dep in the deps.edn file
❯ cat deps.edn
{:deps {com.github.seancorfield/honeysql {:mvn/version "2.4.1066"}}
:aliases
{:demo {:exec-fn clojure.core/println}}}
# check the classpath and both are there
❯ clj -Sdeps '{:deps {criterium/criterium {:mvn/version "LATEST"}}}' -Spath
src:/Users/dan/.m2/repository/com/github/seancorfield/honeysql/2.4.1066/honeysql-2.4.1066.jar:/Users/dan/.m2/repository/criterium/criterium/0.4.6/criterium-0.4.6.jar:/Users/dan/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar:/Users/dan/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar:/Users/dan/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar
# can run the exec fn with the `demo` alias
❯ clj -Sdeps '{:deps {criterium/criterium {:mvn/version "LATEST"}}}' -X:demo :a 1
{:a 1}Oh. Are you wanting to use an alias defined in a dependency?
Yes, the alias is defined in myproject above.
Gotcha. I don’t believe that is supported
Ah, 😞
I can just rearrange my deps file for this.
Put an alias with the dep and exec fn info in your .clojure/deps.edn file and you can invoke it easily
No need for inline deps and such at that point
Cool, will do!
I imagine the reasoning is that aliases are not namespaced. So your class path could have arbitrarily many aliases with the same same
Makes sense, I'm sure there are a lot of :build aliases out there.
And lots of :dev. It would be cool if you could specify them with the dep name. But I suppose you’d have to be careful with which version is selected if multiple are specified by your dependency tree
Yeah, my thought last night (exactly what you suggested) was something like:
clojure -Sdeps '{:aliases {:my-tool {com.github.markbastian/my-app
{:git/url ""
:sha "..."}}}}' \
-X:my-tool:my-alias my-app.main/run But that has some ambiguity about the nested aliasing. For now I'll just do exec fn.