tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2020-11-06T16:33:10.262700Z

@seancorfield: would you take a PR to refactor the bulk of this function into a new function that does everything except call System/exit?

2020-11-06T16:34:15.263400Z

oh actually looks like it’s not system-exit that is the problem… but shutdown-agents

2020-11-06T16:35:12.264400Z

well the system/exit is also bad as it kills my repl when I make a mistake in the config

seancorfield 2020-11-06T16:36:21.265700Z

It calls System/exit in multiple places.

2020-11-06T16:36:33.266300Z

yeah so I’ve seen

alexmiller 2020-11-06T16:36:41.266500Z

I often try to separate the shutdown-agents/System.exit type stuff into a wrapper

2020-11-06T16:36:48.266800Z

yeah me too

2020-11-06T16:36:57.267300Z

that’s what I’m suggesting

seancorfield 2020-11-06T16:37:37.268Z

Yeah, I would normally but I haven't quite gotten there yet.

seancorfield 2020-11-06T16:40:59.269200Z

There's also the call to help-and-die in there. I'll give it some thought this weekend.

2020-11-06T16:41:27.269600Z

shall I make an issue for it?

2020-11-07T13:32:39.338200Z

Thanks sean, sorry I didn’t get around to this yesterday.

seancorfield 2020-11-07T18:44:49.367600Z

NP.

seancorfield 2020-11-07T20:53:40.367800Z

@rickmoynihan release 1.1.133 has this refactoring so you can use hf.depstar.uberjar/run* from the REPL now. Same args as hf.depstar.uberjar/run but it returns a hash map for success/failure. The old entry points all still call (shutdown-agents) or (System/exit 1).

seancorfield 2020-11-07T20:53:51.368Z

Follow-up in #depstar if you want.

seancorfield 2020-11-06T16:41:44.270100Z

Sure. It'll be a good reminder for me.

alexmiller 2020-11-06T16:42:34.270800Z

another option is to parameterize the "on-exit" function

borkdude 2020-11-06T16:45:22.271900Z

I usually write a -main and main. Main only returns the exit code (or a map with exit code) and -main does System/exit + shutdown-agents

borkdude 2020-11-06T16:45:30.272200Z

I then use main in my tests

2020-11-06T16:46:33.272900Z

yeah that’s the same pattern I do… though this isn’t main but an :exec-fn not that it makes much difference.

2020-11-06T16:47:24.273500Z

it lets you essentially test command line opts etc

borkdude 2020-11-06T16:49:04.275600Z

yes, this is how I test all my CLIs using the exact same input as from the command line

2020-11-06T16:51:43.277900Z

Whilst I’m hear, as you may have seen I’ve been tweaking deps-deploy to support the new -X stuff. If you’re going to use deps-deploy however; you essentially need to use depstar (or similar), so it’d be good if these tools could be aligned a bit to respect the same keyword vocabulary. How do people feel about that? Similarly in the deps-deploy changes I made I thought it would be nice to use :mvn/version as it means the same as in tools.deps. However I also wanted :mvn/artifact-id and :mvn/group-id etc. Would those terms in principle be the same as tools.deps / tools.build etc might use? Is it legitimate for me to coin keys in the mvn namespace?

alexmiller 2020-11-06T16:52:48.278300Z

to use in what context?

alexmiller 2020-11-06T16:53:12.279100Z

like in calling with -X or something?

2020-11-06T16:53:27.279400Z

yeah precisely, my patches to deps-deploy allow you to override the :mvn/version via :exec-args and the cli, but also :mvn/artifact-id etc…

alexmiller 2020-11-06T16:53:46.279800Z

probably won't line up to tools.build but I don't know if you should care

2020-11-06T16:54:35.280500Z

well I don’t know what tools.build does… so hard to know if I should care or not 😀

2020-11-06T17:03:17.287900Z

I guess I have a slightly deeper question here though… Which is essentially how deep does RDF’s influence over best practice around keywords in clojure go? Rich has mentioned RDF publicly multiple times over the years. And clojure’s namespaced keywords etc are essentially equivalent to predicates etc. The promoted strategy to handling them has been “if they have the same meaning” it’s fine to reuse them (open world, open for extension etc…). However the linked-data world also has a convention of only coining new terms in namespaces you own. However clojure best practice glosses over that here. Does tools.deps own :mvn, is it legitimate for me to coin keywords in that namespace?

2020-11-06T17:03:55.288700Z

Also is the concept of keyword vocabularies perhaps a useful one?

dpsutton 2020-11-06T17:03:59.288800Z

What is "RDF"?

2020-11-06T17:05:28.289500Z

https://www.w3.org/TR/rdf11-primer/

👍 1
2020-11-06T17:08:01.289900Z

TLDR; A web-scale datomic-like data model described as a set of W3C standards and practices for how people can build databases to support a global graph of knowledge

alexmiller 2020-11-06T17:08:09.290200Z

I do not consider tools.deps to "own" :mvn

alexmiller 2020-11-06T17:09:13.291100Z

qualifiers and their usage are contextual. spec argues for sufficient qualification to create a universe of unambiguous attribute definitions

👍 1
alexmiller 2020-11-06T17:10:01.292200Z

in more limited contexts (inside your project or inside another appropriately scoped data context), less qualification may be sufficient

alexmiller 2020-11-06T17:10:51.293Z

deps.edn has a competing design constraint of wanting to be succinct as this is a format people are frequently writing

2020-11-06T17:11:29.293600Z

(Also acknowledged by Rich to be a big influence on the design of clojure and datomic too)

alexmiller 2020-11-06T17:11:38.293900Z

we ended up leaning more on the latter constraint in that balance

2020-11-06T17:13:49.295500Z

Thanks for that @alexmiller, that’s essentially my perception too. What then do you think of collaborating around common shared definitions like :mvn/version etc and agreeing in principle on other ones to avoid future conflict in areas such as this?

alexmiller 2020-11-06T17:14:17.295900Z

for the purposes of invoking tools, I don't think there's any need to collaborate

alexmiller 2020-11-06T17:14:34.296200Z

and I don't see it as conflict

2020-11-06T17:16:58.298600Z

well it’s not a conflict if I chose :mvn/group-id and you choose :mvn/groupid, but it is irritating if we mean the same thing and our terms flow through the same channels. It would be a potential conflict if we both independently chose :mvn/repository but I defined it as a map, and you a string; and they happened to flow through the same context.

alexmiller 2020-11-06T17:18:17.299500Z

I don't see them flow through the same channels or exist in the same context, which is why I say this is not a conflict

alexmiller 2020-11-06T17:19:05.300200Z

really, I'd say neither of these tools "own" :mvn. use a qualifier you own if you want to own it.

alexmiller 2020-11-06T17:19:31.300500Z

otherwise, don't complain when it conflicts :)

seancorfield 2020-11-06T17:25:11.306700Z

depstar's arguments to -main are pretty fixed at this point, and I've just named the :exec-args after the long-form command-line arguments I believe. Changing them would break backward compatibility so I don't want to do that. Re: deps-deploy -- I think it's pretty important that pom.xml be the source of truth for the group/artifact/version -- at least insofar as the version that is included in the JAR and uploaded to Clojars with the artifact -- so I don't think it's a good idea to override the version in deps-deploy and end up with the internal POM not matching the external POM.

2020-11-06T17:26:54.308200Z

Well that’s certainly pragmatic. I’ll take that as permission to follow your example and use :mvn/group-id here. I mean it seems sensible to follow similar conventions for human reasons.

vlaaad 2020-11-06T17:27:01.308500Z

And then there is me who thinks that pom.xml it's just a temporary file that should be deleted as soon as deployment is done

seancorfield 2020-11-06T17:27:25.308900Z

At this point, I would prefer to defer all of this to tools.build but I don't know whether deployment is in scope for that (we have local mvn-install already in t.d.a but no remote deployment).

seancorfield 2020-11-06T17:27:58.309800Z

I don't want to have to keep maintaining a community tool if there is an official tool from the core Clojure team that does the same job.

2020-11-06T17:28:31.311Z

@seancorfield: yeah that’s fair… I’d much rather overriding the :mvn/version etc happened in depstar. I said this the other day in fact.

alexmiller 2020-11-06T17:28:41.311600Z

I think deployment is one of many things that could be invoked by tools.build

alexmiller 2020-11-06T17:29:08.312700Z

whether that's something provided as part of tools.build or community is a separate question. I've looked at it in depth, have a lot of opinions, have not built it.

seancorfield 2020-11-06T17:29:22.313Z

@vlaaad Well, the reality is that there's a lot of stuff in pom.xml that other tooling out there relies on, far beyond the minimum that clojure -Spom produces, so you pretty much have to maintain that information somewhere under version control.

seancorfield 2020-11-06T17:30:45.316200Z

@rickmoynihan Yeah, there are parts of pom.xml that it would be nice for depstar to be able to override but if you override <version>, you pretty much have to override the SCM <tag> to match, because of tooling that uses that.

alexmiller 2020-11-06T17:30:49.316300Z

the code under -Spom has been refactored to make it more amenable to having more options/features and I think longer term that's going to be something we push to primarily being done as part of a build, with probably ever-increasing scope to refine as part of a build

2020-11-06T17:30:54.316400Z

Yeah… For my needs I think treating pom.xml as a template, and moving my override feature from deps-deploy into depstar would make most sense.

2020-11-06T17:31:26.316500Z

yeah @dominicm mentioned this the other day… that’s trivial to do too though.

alexmiller 2020-11-06T17:31:50.317200Z

there are all sorts of special cases you might want to handle in making a pom for deployment

seancorfield 2020-11-06T17:32:24.317900Z

A guiding principle for depstar is no additional dependencies so the more functionality it accretes, the more I end up rewriting other tooling into the depstar codebase.

alexmiller 2020-11-06T17:32:29.318100Z

many require some kind of data manipulation you'll want to do during a build

vlaaad 2020-11-06T17:32:32.318200Z

Of course, I just think that pom.xml is a horrible storage for this information, since there is a lot of complexity with regards to updating it

alexmiller 2020-11-06T17:33:54.319600Z

just fyi on tools.build - it exists, it has a lot of functionality but we are trying to finalize a lot of the details around how tasks are defined, stitched together, invoked, etc. b/c that kind of affects everything, we're delaying the public release of it but we'll get there.

seancorfield 2020-11-06T17:33:58.319700Z

Oh totally agree! XML is a horrible source format -- but we're "not supposed to use" deps.edn for this stuff, which is where I would otherwise expect it to be... although with :exec-args etc, that's getting more reasonable and "sanctioned" as appropriate by the core team.

alexmiller 2020-11-06T17:34:22.320Z

I have no opposition to using that name :)

👍 1
seancorfield 2020-11-06T17:35:08.321Z

And I'm still going to bleat on and on about some sort of built-in solution for either the monorepo case or where folks want to combine/insert an extra "master" deps.edn file into the t.d.a mix that everything should then use 🙂

2020-11-06T17:35:25.321300Z

Why no additional dependencies? A stable xml lib would be handy, and tools are usually separate from an apps :deps anyway.

seancorfield 2020-11-06T17:35:33.321600Z

(ideally, in t.d.a so that tooling could rely on it easily)

2020-11-06T17:35:50.321800Z

even tools.deps has dependencies!

2020-11-06T17:36:10.322200Z

and clojure 🙂

seancorfield 2020-11-06T17:36:35.322800Z

Some sort of "include" or "reference" functionality in deps.edn would work for that -- but I think you've said the core team are opposed to going down that path @alexmiller?

seancorfield 2020-11-06T17:37:12.323300Z

Look at the way depstar works and you'll see: it packages up what it finds on the classpath you used to run it, simply excluding itself.

alexmiller 2020-11-06T17:37:14.323500Z

my initial lean would be towards an additional deps.edn source but haven't talked about it enough

seancorfield 2020-11-06T17:37:56.323600Z

That ensures you get exactly what you expect in the JAR based on the aliases you provide, and mean that you don't have to tell depstar itself how to read/combine aliases/`deps.edn` etc.

2020-11-06T17:38:02.323800Z

It also allows you to set an explicit :classpath though right?

seancorfield 2020-11-06T17:38:23.324Z

Yes, that's an alternative option but I don't want it to be the default.

seancorfield 2020-11-06T17:38:54.324200Z

Lots of people seem to struggle with the other JAR-makers out there and end up at depstar because it is simple and does the obvious, intuitive thing.

2020-11-06T17:40:07.325400Z

sounds more like easy to me… simple would be having the :classpath supplied explicitly.

seancorfield 2020-11-06T17:40:17.325800Z

That would satisfy me too. I'd like to get away from my current CLJ_CONFIG hack, and I'd like individual developers to be able to keep using their own ~/.clojure/deps.edn file for dev/test stuff without us needing to repro a common core set into our "master" deps.edn file 🙂

👍 1
seancorfield 2020-11-06T17:42:27.326100Z

The original version of depstar that I inherited had pretty much no options and just created a JAR from the classpath. It was about as simple as it could be. Adding AOT and main-class and other stuff has made it less simple as a tool, but still easy 🙂

2020-11-06T17:42:40.326300Z

FWIW I think this would be useful too.

2020-11-06T17:50:49.326500Z

yeah I understand, and there’s nothing wrong with easy. It just sounds like that’s a requirement for the uberjar side of depstar; but the library side is I think a far simpler problem. Perhaps it should be split into two separate libraries, depstar.jar and depstar.uber?

seancorfield 2020-11-06T17:52:43.326800Z

It could be refactored to keep those two things separated. Lots of things could be done with depstar but, right now, I'm waiting to see where tools.build ends up.

seancorfield 2020-11-06T17:53:17.327Z

Like I say, I don't want to keep maintaining a community tool when there's an official core Clojure team tool that does the "same" job.

seancorfield 2020-11-06T17:53:48.327200Z

If it seems like tools.build won't handle the cases that depstar can handle, then I'll be happy to invest a lot more time into it.

2020-11-06T17:54:53.327400Z

that’s fair enough 🙂 but I need solutions now, not in 2+ years 🙂 Being able to build and deploy a library into a private s3 bucket is a common requirement that’s far more awkward than it should be right now.

2020-11-06T18:01:22.330300Z

@alexmiller: Which problem does tools.build solve more of? Orchestrating arbitrary tasks together, or providing ways to build jars, deploy stuff etc? My feeling is that it’s more like make than a way to build jars? Is that right? Or is it both? I appreciate you don’t want to go into too much detail; but it’d be useful to know if depstar etc might be replaced wholesale by it; or whether something like depstar would just integrate with it?

2020-11-06T18:03:01.331200Z

Ok sorry folks this is going to have continue another time… Many thanks to everyone involved in the discussion. I hope you all have fab weekends. 👋 👋

seancorfield 2020-11-06T18:17:05.331300Z

https://github.com/seancorfield/depstar/issues/45

alexmiller 2020-11-06T19:01:51.333700Z

I would love to see the built-ins become de facto defaults and make them great with community help

dominicm 2020-11-06T19:41:45.334400Z

I'm very curious to see how/if caching is handled. Notoriously difficult task.

alexmiller 2020-11-06T19:45:27.334600Z

caching of?

vlaaad 2020-11-06T20:10:43.334900Z

I would guess caching of task results

👍 1
dominicm 2020-11-06T20:11:53.336500Z

E.g. make

alexmiller 2020-11-06T20:12:01.336700Z

if you mean like compiled classes, that's one thing we're still thinking through

dominicm 2020-11-06T22:46:40.337200Z

Fwiw, I think this would be a valuable article on http://clojure.org. Explaining the purposes of namespacing and when you can skip it, when to use #db/id instead of #com.datomic/id Or #datomic/id.