tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2020-11-20T14:05:52.465400Z

in deps.edn, is it possible to have one alias include another?

dominicm 2020-11-20T14:10:08.465500Z

@millettjon You can have an alias include directories from another like so:

:aliases {:foo-paths ["src"] :some-alias {:extra-paths [:foo-paths "some-alias-path"]}}

dominicm 2020-11-20T14:10:31.465600Z

For including dependencies, there's a JIRA for that and you might be able to vote on it there if you have an account.

2020-11-20T14:14:10.466300Z

are you sure?

clj -Sdeps '{:paths ["foo"] :aliases {:foo {:extra-paths ["bar"]} :bar {:extra-paths [:foo "baz"]}}}' -A:bar -Spath

=> baz:foo:...
without paths from alias :foo

2020-11-20T14:16:15.466600Z

Looks like this is the JIRA ticket: https://clojure.atlassian.net/browse/TDEPS-170

dominicm 2020-11-20T14:16:45.466800Z

@delaguardo You changed my example :)

2020-11-20T14:19:55.467Z

Thanks. I would use both in this case.

2020-11-20T14:22:28.468900Z

is there a way to tell cli where to search for maven settings.xml ? maven allows to override the location with -s (ex: mvn -s myptah/settings.xml install)

2020-11-20T14:24:14.469100Z

@dominicm right, I didn’t know that you can have a vector of strings as a value for alias keyword. Not sure if this is a part of official api thought

borkdude 2020-11-20T14:30:18.469300Z

Huh, is this new?

borkdude 2020-11-20T14:31:17.469500Z

And does it work or not? I see conflicting evidence with @delaguardo's example?

2020-11-20T14:34:16.469700Z

:aliases {:foo ["X"] 
          :bar {:extra-paths [:foo "Y"]}
is working
clj -Sdeps '{:aliases {:foo ["X"] :bar {:extra-paths [:foo "Y"]}}}' -Srepro -A:bar -Spath

=> X:Y:...
but it also is not valid acording the spec in tools.deps.alpha — https://github.com/clojure/tools.deps.alpha/blob/master/src/main/clojure/clojure/tools/deps/alpha/specs.clj

2020-11-20T14:34:34.470Z

I can see the jira ticket but don't see how to vote. Maybe I don't have the right access?

2020-11-20T14:35:21.470300Z

Yeah I didn't see it mentioned anywhere but this is the second time I have wanted to use include functionality.

borkdude 2020-11-20T14:35:21.470500Z

That is a common issue with JIRA. It sucks.

☝️ 2
dominicm 2020-11-20T15:14:18.470900Z

@delaguardo this is part of the official API, yes.

dominicm 2020-11-20T15:14:25.471100Z

This is new in tools deps

2020-11-20T15:19:42.471300Z

do you know where this declared? Can’t find it in cli guide or reference

2020-11-20T15:23:15.471600Z

also (if this is new) when it was introduced?

2020-11-20T15:24:54.471800Z

nwm, found it in changelog

borkdude 2020-11-20T15:25:46.472Z

when?

2020-11-20T15:26:12.472200Z

in 0.9.745

2020-11-20T15:26:46.472400Z

• Added support for using data stored in aliases as :paths

borkdude 2020-11-20T15:26:47.472600Z

do you have a link to the changelogs? I never know where to look: in brew install clojure or tools-deps?

2020-11-20T15:29:06.473200Z

but this is soooo confusing

clj -Sdeps '{:aliases {:foo ["x"]}}' -A:foo -Spath

=> "src:..."
seems like this isn’t working in that case

borkdude 2020-11-20T15:29:24.473500Z

I would have never guessed that > Added support for using data stored in aliases as :paths this would mean the above

2020-11-20T15:29:36.473700Z

same

alexmiller 2020-11-20T15:43:03.474Z

no

alexmiller 2020-11-20T15:43:37.474600Z

if you want to file an https://ask.clojure.org request for that, I don't think we have any such question/ticket right now

2020-11-20T15:48:47.474900Z

Will do ! thanks @alexmiller

2020-11-20T15:54:51.476300Z

I have a question - should this clj -Sdeps '{:aliases {:foo ["x"]}}' -A:foo -Spath work the same as clj -Sdeps '{:aliases {:foo {:extra-paths ["x"]}}}' -A:foo -Spath ? right now I’m getting different results. In first case there is no “x” in my path

alexmiller 2020-11-20T16:03:17.476600Z

the first is not a thing

alexmiller 2020-11-20T16:03:31.476900Z

not sure what you're expecting there?

alexmiller 2020-11-20T16:04:21.477700Z

unless you do clj -Sdeps '{:paths [:foo] :aliases {:foo ["x"]}}' -A:foo -Spath

2020-11-20T16:04:36.478Z

just curiosity as an example this clj -Sdeps '{:aliases {:foo ["x"] :bar {:extra-paths [:foo]}}}' -A:bar -Spath is working wierdly

alexmiller 2020-11-20T16:04:49.478200Z

as it should

2020-11-20T16:06:26.479800Z

that is what I found today in the slack thread was surprised because can’t remember mention of that in cli guide or reference also specs in tools.deps.alpha is not allowing such aliases neither as in API.md

alexmiller 2020-11-20T16:08:48.480200Z

there is an example in https://clojure.org/reference/deps_and_cli#_paths but may be under-doc'ed :)

👍 1
alexmiller 2020-11-20T16:09:04.480500Z

specs may be lagging

2020-11-20T16:10:33.481200Z

looks like :aliases become a little bit overloaded key

alexmiller 2020-11-20T16:20:26.481800Z

not overloaded at all, just very generic. an alias is a name for a data structure.

2020-11-20T16:23:52.484200Z

and this data now is context specific + depend on it’s shape, isn’t it?

alexmiller 2020-11-20T16:26:17.484500Z

dependent on how you want to use it, it's just data

2020-11-20T16:30:56.487300Z

sure, but this clj -Sdeps '{:aliases {:foo "x"}}' -A:foo -Spath will throw

clj -Sdeps '{:aliases {:foo "x"}}' -A:foo -Spath               
Error building classpath. nth not supported on this type: Character
java.lang.UnsupportedOperationException: nth not supported on this type: Character
this exception is telling me that data is used in a context hidden from me. So for me this is not just data

alexmiller 2020-11-20T16:31:55.487500Z

well, I'd say that's a bug

alexmiller 2020-11-20T16:32:47.488Z

should either be ignored or have a better error in that case, feel free to log at http://ask.clojure.org

2020-11-20T16:35:01.488700Z

sure, I will report it btw, this clj -Sdeps '{:paths [:foo] :aliases {:foo "x"}}' -Spath doesn’t give me an exception

alexmiller 2020-11-20T16:36:15.489500Z

iirc, it flattens so it's little loosey goosey about the colls there atm, still deciding what to allow

2020-11-20T16:43:59.492300Z

I have an issue bringing in a .jar that relies on a pom.xml that relies on Dropwizard. Having a little trouble figuring out where the issue really lies. clj -Spath gives me this error for all the .jar's dependencies: [ERROR] Failed to determine Java version for profile.... I can run the jar just fine with plain old Java. It only becomes a problem when I try to bring it into my project. Here it is in my deps.edn: com.plaid/quickstart {:local/root "src/usermanager/java/target/quickstart-1.0-SNAPSHOT.jar"}

2020-11-20T16:44:52.492900Z

The docs tell me this is the right behavior ("If the jar includes a pom.xml file, it will be used to find transitive deps"). FWIW, each dependency is enumerated thusly: <groupId>io.dropwizard</groupId>, <artifactId>dropwizard-bom</artifactId>, <version>${dropwizard.version}</version>. With the version of Dropwizard resolving as 1.3.2. That what it seems to be choking on, based on the error.

2020-11-20T16:45:37.493300Z

Should I just build my own uberjar?

alexmiller 2020-11-20T16:47:19.494600Z

resolving pom files is kind of a pain in the ass (super poms, variables, env vars, etc) - it is certainly possible for the pom inside a jar to be insufficient to actually resolve the dep set

2020-11-20T16:49:25.497200Z

Well, I have the source. So I can roll it again. Maybe that's the easiest way? this .jar came in the repository.

seancorfield 2020-11-20T16:49:51.497600Z

@delaguardo There's an example in the docs of this https://clojure.org/reference/deps_and_cli#_paths

alexmiller 2020-11-20T16:49:56.497900Z

if you have a concrete repro, would be happy to see a question on https://ask.clojure.org with that so I can look at it. at the very least, would like to fail gracefully and let you supply those deps explicitly.

2020-11-20T16:50:03.498300Z

Debugging it from the clojure side seems pretty silly if it's not immediately obvious what's going wrong.

seancorfield 2020-11-20T16:50:08.498400Z

{:paths [:clj-paths :resource-paths]
 :aliases
 {:clj-paths ["src/clj" "src/cljc"]
  :resource-paths ["resources"]}}

seancorfield 2020-11-20T16:50:36.499Z

Here are the CLI release notes: https://clojure.org/releases/tools

2020-11-20T16:50:43.499400Z

I do. It's Plaid's API Java code... so it's also something that isn't too obscure.

alexmiller 2020-11-20T16:51:14.000400Z

"Failed to determine Java version for profile" means that there is a maven profile that uses maven's Java version stuff (lets you select per-java version deps)

2020-11-20T16:51:39.000900Z

I can put the question there. I'll have to give a bit of a think of how to phrase it succinctly.

alexmiller 2020-11-20T16:51:54.001500Z

I think maybe that requires JAVA_HOME env var

alexmiller 2020-11-20T16:52:00.001900Z

you could try setting that and seeing if it works

seancorfield 2020-11-20T16:52:19.002300Z

Ah, I see Alex linked you to the same example in the docs (but at least the CLI releases link is new to this thread).

2020-11-20T16:52:23.002600Z

Got it. I'll play a little more and post something on http://ask.clojure.org. Thanks @alexmiller!

2020-11-20T16:53:07.002700Z

yes, this one is new, thanks!

seancorfield 2020-11-20T16:54:09.002900Z

You can also use aliases for :exec-args to point to a data structure that is then used as the arguments to the :exec-fn

2020-11-20T16:55:39.003200Z

as a complete replacement of exec-args? like :exec-args :one-of-aliases ?

seancorfield 2020-11-20T16:55:46.003400Z

So far those are the only two places where the CLI/t.d.a itself allows/uses aliased data. Yes, like that.

seancorfield 2020-11-20T16:56:25.003600Z

(the :exec-args usage is not documented on that page, unfortunately)

seancorfield 2020-11-20T16:57:05.003800Z

With the Clojure basis available to any program run from the CLI, you can also read the merged deps.edn data and access aliased data inside your program at runtime.

2020-11-20T17:00:32.004Z

I wish to have ability to provide custom data literals for deps.edn reader. then those tiny references to data in aliases can be colored as #aliases/ref :some-alias and allows to be used as a partial replacement for exec-args

2020-11-20T17:01:41.004200Z

without this twick it is hard to say what is going on here :paths [:foo "bar"] without reading documentation (with blanks 😞 )

seancorfield 2020-11-20T17:04:49.004400Z

Feel free to post requests to improve the docs on http://ask.clojure.org -- or if you've signed the Contributor's Agreement, you could submit PRs directly to https://github.com/clojure/clojure-site/pulls (but probably best to discuss with @alexmiller first to see how he'd like this clarified). Suggestions for changing the deps.edn file format itself can go on http://ask.clojure.org