tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
practicalli-john 2020-09-06T00:02:52.414Z

@seancorfield To package Clojure for Ubuntu, then I'd suggest a personal package archive (PPA), new release of Clojue can be pushed to this as soon as they are ready. There is a specific process for creating package to learn. Packages can be built for each release of Ubuntu (e.g. current long term support and intermediate releases) and published on the PPA. The relevant packages can be submitted for each new Ubuntu release (6 month cycle). There are also other options such as snaps and flatpack, but a proper *.deb package is much nicer in my opinion as it ensures there are no conflicts with other software installed via the package manager. There is a Leiningen package for Ubuntu, so some of the experience from that can be used. For Arch, I seem to remember that @dharrigan packages up clj-kondo , so I assume his work can be of help for packing to the Arch User Repository (AUR).

alexmiller 2020-09-06T00:13:24.415Z

No, clj and tools.deps were developed together

practicalli-john 2020-09-06T01:12:08.427400Z

@alexmiller so far very positive changes. I like that -M feels similar in concept to the :main in Leiningen, in part easing the move from Leiningen to CLI tools. My current thoughts are around edge cases where I have multiple aliases containing :main-opts and how to use them together with certainty rather than optomism. I have tried to elaborate some options in this gist https://gist.github.com/jr0cket/6fae7576a87d5d32eda4be2253f41692

2020-09-06T01:18:25.429500Z

I like the new features. :ns-default and :ns-aliases look very useful. The -P option is great, and could be even nicer if it (optionally) output a map of the resolved dependencies, which could be used to make reproducible builds.

2020-09-06T01:18:43.429700Z

To be honest, I’ve always found the different merging rules confusing and never really understood their purpose. Why not just have -A to specify the aliases to merge, and -e, -x (equivalent of the :exec-fn key) or -m (equivalent of the :main-opts key) to specify or override what should be run. Maybe with a -r for a future repl specifier. If the config is not specific, define a precedence for :exec-fn and :main-opts. This would separate (decomplect, dare I say?) merging of aliases from specifying what to invoke, which I, for one, find simpler to understand.

seancorfield 2020-09-06T01:29:56.429800Z

@jr0cket Multiple aliases containing :main-opts is an "issue" today (stable) as well as tomorrow (prerelease), and the answer is the same as it has always been -- per the documentation -- "If multiple maps with these keys are activated, only the last one will be used" -- see https://clojure.org/reference/deps_and_cli#_aliases which explains how each different type of option is "merged" when multiple appear. The same wording is present in the prerelease reference docs, but spread out over multiple sections, rather than gathered together in one section.

seancorfield 2020-09-06T01:30:17.430Z

Is that not "certainty" enough?

alexmiller 2020-09-06T01:40:59.436900Z

Every build outputs a lib map in the cache dir with this info (-Sdescribe tells you where)

seancorfield 2020-09-06T01:41:03.437100Z

@hugod In the stable version, -M didn't pick up any items from the alias(es) except :main-opts and in the first version of -X on the prerelease track didn't pick up any items from the alias(es) except the fn/args spec as I understand it. In the latest prerelease, both of those pick up everything in the alias(es) specified and then -M runs the :main-opts while -X runs the function invocation -- and -A is slated for being similar (picking up everything in the alias(es)), but ultimately just running the REPL, not executing main/function stuff. That's why I proposed keeping -R and growing it to pick up everything in the alias(es) and just running the REPL -- -R for REPL. But, either way, it's a much more streamlined piece of logic: all three options pick up all options and then each one of -A (or maybe -R?), -M, and -X selects what execution model is used.

seancorfield 2020-09-06T01:41:33.437800Z

It's nice and streamlined. And I think it removes a lot of confusion about which parts of an alias get picked up by which options.

2020-09-06T01:49:08.441300Z

didn’t realise that 🙂

2020-09-06T01:50:29.441500Z

Having -M, -X, and -A pick up everything certainly seems like an improvement. I would still find it simpler to just have the one option for specifying aliases, and then options for specifying what to run. Using lower case for the latter would allow for the cli to maintain backward compatibility iiuc.

seancorfield 2020-09-06T01:52:13.442300Z

I suspect there would be confusion, since -e, -m, and -r are existing main options today (for clojure.main).

seancorfield 2020-09-06T01:55:19.444600Z

You'd also need to specify both an option to collect aliases and then an additional option to specify the action to take. With the prerelease direction, you'd only need one option: either -X for aliases and execute function, or -M for aliases and main function, or -A for aliases and the REPL (at some point, given -A currently still executes main opts).

2020-09-06T02:03:31.445900Z

I was suggesting -e and -m kept their current meaning, and implied invoking clojure main.

seancorfield 2020-09-06T02:04:48.446600Z

But :main-opts can contain a combination of those so I don't think that's going to be intuitive.

seancorfield 2020-09-06T02:05:05.447Z

(`:main-opts` can also contain -i and -r options)

mike_ananev 2020-09-06T04:59:43.451700Z

@alexmiller Is it possible to add functionality of generation distributionManagement section to 'clj -X:deps mvn-pom' command? I need to distribute my artefacts written in Clojure to corporate Nexus. To do this I need section in pom.xml:

<distributionManagement>
  <repository>
    <id>releases</id>
    &lt;url&gt;<http://mycompany/nexus/content/repositories/releases>&lt;/url&gt;
  &lt;/repository&gt;
  &lt;snapshotRepository&gt;
    &lt;id&gt;snapshots&lt;/id&gt;
    &lt;url&gt;<http://mycompany/nexus/content/repositories/snapshots>&lt;/url&gt;
  &lt;/snapshotRepository&gt;
&lt;/distributionManagement&gt;
Building and deploying artefacts is performed in corporate Jenkins, where I can't manually add this section.

seancorfield 2020-09-06T05:02:03.453400Z

@mike1452 Since clj -X:deps mvn-pom only updates dependencies and a few other bits, so what I tend to do is generate an initial POM, augment it manually, check it in to version control, then just run that command as needed to update the dependencies section (and it leaves all the rest intact).

seancorfield 2020-09-06T05:02:28.454Z

So you could manually add that section, and clj will not overwrite it.

vlaaad 2020-09-06T05:34:48.456200Z

Weekly reminder that reading/updating pom.xml is a workaround for the problem, not a solution :)

☝️ 1
dharrigan 2020-09-06T05:43:53.456400Z

That's right, I do maintain a few Clojure packages on Arch, like clj-kondo, babashka, clojure-lsp. A pleasure to do so 🙂 However, the main Clojure package is part of the Community Repo that is under a different maintainership. It is reguarly updated (last update was 2020-08-26, which brought in Clojure 1.10.1.645).

borkdude 2020-09-06T07:24:12.457700Z

@alexmiller I know tools.deps isn't going to expand ~, but I'd like to know the reason for this. Reason I'm asking is that I'm considering doing this in .clj-kondo/config.edn and would like to know if I'm missing some problems

mike_ananev 2020-09-06T09:31:19.460800Z

@seancorfield Is it possible to exclude clj source files from uberjar using depstar? I need only aot compiled files in uberjar, when distributing it. Also, how do you recommend to compile java source files, when using depstar?

mike_ananev 2020-09-06T09:42:38.461500Z

Is it possible to add to depstar something like this https://gist.github.com/just-sultanov/e2f61734e22e2ed3981216ed9b880bc0 to compile java sources?

borkdude 2020-09-06T09:51:40.462100Z

@mike1452 depstar has this for removing itself: https://github.com/seancorfield/depstar/blob/a542560766cfd2b51d415908885625aa64165cb4/src/hf/depstar/uberjar.clj#L292 I think that can be easily extended to remove other things

borkdude 2020-09-06T09:52:37.462700Z

Ah no, scratch that, that's only for removing something from the classpath.

borkdude 2020-09-06T09:54:02.463500Z

Ah, and that's exposed via -X (not clojure's -X, but depstar's -X)

borkdude 2020-09-06T09:54:27.464Z

so probably something like -X "\.clj$" would work

alexmiller 2020-09-06T11:46:24.465300Z

Because then everyone reading deps,edn has to interpret the file

alexmiller 2020-09-06T11:47:31.466500Z

It’s no longer just edn/read, it’s that plus run magic code

borkdude 2020-09-06T12:32:40.467700Z

Why does it have to be interpreted by anything else than tools.deps which already does interpretation of this entire model?

borkdude 2020-09-06T12:37:17.468900Z

I mean, merge, assoc, etc still works for other tools in this case?

alexmiller 2020-09-06T12:45:56.470600Z

If you have alias data, anyone may be reading it via the basis (without tools.deps, which has a lot of deps)

alexmiller 2020-09-06T12:47:41.471800Z

There are a bunch of tools already reading and manipulating deps.edn. The less they have to know, the better

dominicm 2020-09-06T12:53:27.472700Z

You don't need to remove the clj files anyway. Or is there an additional piece of information?

borkdude 2020-09-06T13:30:12.473800Z

I don’t think this will be a problem for the linter config file. Thank you sir.

seancorfield 2020-09-06T18:33:06.474900Z

The regex-based file exclusion was added in the most recent depstar release @mike1452 -- did the suggestions above work for you?

seancorfield 2020-09-06T18:34:03.475800Z

(you could also specify a classpath that only had the class path, without the src path I suppose, if every piece of source has been compiled?)

seancorfield 2020-09-06T18:35:00.476900Z

As for Java, that's outside the scope of a Clojure tool: compile it yourself and then add that to the classpath (depends on how/where you compile your Java source to .class files).

dominicm 2020-09-06T22:02:13.477200Z

How can I remove org.clojure/clojure from the classpath? I seem to recall a trick to it.

dominicm 2020-09-06T22:03:34.477300Z

(I want to use org.clojure/clojure$sources instead)

alexmiller 2020-09-06T22:39:52.478500Z

Just specify a different coord for it? Or use :override-deps?

alexmiller 2020-09-06T22:41:12.479500Z

Keep in mind that everything calls clojure.main and you need a class for them jvm to invoke

dominicm 2020-09-06T22:45:47.479600Z

I tried using override-deps, maybe I used it wrong.

dominicm 2020-09-06T22:46:52.479700Z

Error building classpath. Coordinate type not loaded for library org.clojure/clojure in coordinate {}

dominicm 2020-09-06T22:57:35.479800Z

(I also tried nil)

seancorfield 2020-09-06T23:25:36.480Z

You need an alias to use :override-deps

dominicm 2020-09-06T23:26:54.481200Z

I used one. But I'm trying to override to remove it and {} didn't work at that removal coordinate.