Fork me on GitHub
#tools-deps
<
2020-11-20
>
millettjon14:11:52

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

dominicm14:11:08

@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"]}}

delaguardo14:11:10

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

dominicm14:11:45

@U04V4KLKC You changed my example :)

millettjon14:11:55

Thanks. I would use both in this case.

delaguardo14:11:14

@U09LZR36F 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

borkdude14:11:18

Huh, is this new?

borkdude14:11:17

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

delaguardo14:11:16

: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

millettjon14:11:34

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

millettjon14:11:21

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

borkdude14:11:21

That is a common issue with JIRA. It sucks.

☝️ 6
dominicm15:11:18

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

dominicm15:11:25

This is new in tools deps

delaguardo15:11:42

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

delaguardo15:11:15

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

delaguardo15:11:54

nwm, found it in changelog

delaguardo15:11:46

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

borkdude15:11:47

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

delaguardo15:11:06

but this is soooo confusing

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

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

borkdude15:11:24

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

seancorfield16:11:08

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

seancorfield16:11:19

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

delaguardo16:11:07

yes, this one is new, thanks!

seancorfield16:11:09

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

delaguardo16:11:39

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

seancorfield16:11:46

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

seancorfield16:11:25

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

seancorfield16:11:05

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.

delaguardo17:11:32

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

delaguardo17:11:41

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

seancorfield17:11:49

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

dominicm14:11:31

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

jmayaalv14:11:28

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)

Alex Miller (Clojure team)15:11:37

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

delaguardo15:11:51

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

Alex Miller (Clojure team)16:11:17

the first is not a thing

Alex Miller (Clojure team)16:11:31

not sure what you're expecting there?

Alex Miller (Clojure team)16:11:21

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

delaguardo16:11:36

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

delaguardo16:11:26

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

Alex Miller (Clojure team)16:11:48

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

👍 3
delaguardo16:11:33

looks like :aliases become a little bit overloaded key

Alex Miller (Clojure team)16:11:26

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

delaguardo16:11:52

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

Alex Miller (Clojure team)16:11:17

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

delaguardo16:11:56

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

Alex Miller (Clojure team)16:11:55

well, I'd say that's a bug

Alex Miller (Clojure team)16:11:47

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

delaguardo16:11:01

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

Alex Miller (Clojure team)16:11:15

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

schmudde16:11:59

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"}

schmudde16:11:52

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.

schmudde16:11:37

Should I just build my own uberjar?

Alex Miller (Clojure team)16:11:19

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

schmudde16:11:25

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

Alex Miller (Clojure team)16:11:56

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.

schmudde16:11:03

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

schmudde16:11:43

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

Alex Miller (Clojure team)16:11:14

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

schmudde16:11:39

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

Alex Miller (Clojure team)16:11:54

I think maybe that requires JAVA_HOME env var

Alex Miller (Clojure team)16:11:00

you could try setting that and seeing if it works

schmudde16:11:23

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