tools-build

cap10morgan 2022-10-21T15:48:22.851209Z

anyone using codox with tools.build? seems like it would need a way to inject the basis into it or just shell out from tools.build and run the deps.edn -X:codox alias. o/w it complains it can't find any of the project's namespaces on the classpath. anyone figured out anything better for that or similar libs?

Alex Miller (Clojure team) 2022-10-21T16:26:29.942829Z

You should be able to make a basis to do whatever you need?

Alex Miller (Clojure team) 2022-10-21T16:27:09.011719Z

I guess you’re trying to run it in the builds process?

cap10morgan 2022-10-21T16:39:27.721409Z

Yeah, I tried calling codox/generate-docs from my build.clj. I hadn’t tried adding the paths to the build alias. I’ll give it a shot.

Alex Miller (Clojure team) 2022-10-21T16:50:27.337589Z

there's no magic here - you're just running a Clojure program with a classpath. If you need something additional on the classpath, just add it. :)

cap10morgan 2022-10-21T16:51:28.547789Z

Yeah. I just would have thought it inherited the top-level paths if I didn’t override them in the alias

Alex Miller (Clojure team) 2022-10-21T16:52:12.245629Z

yeah, it intentionally does not

👍 1
Alex Miller (Clojure team) 2022-10-21T16:53:18.224399Z

there's some extended info on this at https://clojure.org/guides/tools_build#_setup

Alex Miller (Clojure team) 2022-10-21T16:54:03.150899Z

"Tools executed with -T:an-alias remove all project deps and paths, add "." as a path, and include any other deps or paths as defined in :an-alias."

Alex Miller (Clojure team) 2022-10-21T16:54:43.988829Z

In general, tool execution (-T) means "run a separate tool" and thus your project deps/paths are not included

cap10morgan 2022-10-21T16:56:58.791259Z

gotcha. makes sense. thanks!

cap10morgan 2022-10-21T17:07:09.779109Z

then it complains about not being able to find the top-level :deps referenced in macros when codox tries to generate the docs

cap10morgan 2022-10-21T17:07:49.376079Z

codox might just be a hard one to tool-ify w/o some modifications huh?

Alex Miller (Clojure team) 2022-10-21T17:31:13.829619Z

I’m not understanding that

Alex Miller (Clojure team) 2022-10-21T17:31:57.547729Z

You might need to add the :deps too

cap10morgan 2022-10-21T17:32:08.645929Z

Yeah, me neither really. Just throwing macro expansion errors about not finding any libs I’m pulling in via top-level deps

Alex Miller (Clojure team) 2022-10-21T17:33:05.545219Z

As I said above, you don’t have your :deps when running a tool, unless you pull them in

cap10morgan 2022-10-21T17:33:34.729669Z

Yeah I’ll just leave it as a process invocation for now

cap10morgan 2022-10-21T17:34:22.809749Z

Maybe open an issue about accepting a basis in codox and see what they think

cap10morgan 2022-10-21T17:34:32.660329Z

(Maybe I will, that is)

borkdude 2022-10-21T18:25:42.882769Z

You could also give #quickdoc a "quick" try, it doesn't load the code but uses clj-kondo analysis (for better or worse!)

cap10morgan 2022-10-21T18:26:11.809399Z

ah, cool. I'll check it out, thanks!

Alex Miller (Clojure team) 2022-10-21T16:28:08.248499Z

You could add the :paths to the build process alias but maybe you would want to shell out for isolation, not sure

cap10morgan 2022-10-21T19:57:14.779639Z

Is accepting a tools.deps.alpha basis value the idiomatic way for libraries to work with tools.build programs? Or is there a better way to integrate? I've seen some that do accept that as an optional arg, but wondering if it's the best approach or not.

Alex Miller (Clojure team) 2022-10-21T19:58:43.758979Z

I think unhelpfully I will say it depends :)

Alex Miller (Clojure team) 2022-10-21T19:59:22.490319Z

for things that expect to be run in some classpath context, then probably no - you should define the context in which you're expecting to be run

cap10morgan 2022-10-21T20:01:34.243899Z

I assume you mean something broader here than just "put everything you'll need into the build alias"?

cap10morgan 2022-10-21T20:05:07.799039Z

makes me wonder if there'd be any benefit to a tools.build.api fn along the lines of clojure-command or exec-alias? perhaps there's not much to be gained beyond what you get with (b/process {:command-args ["clojure" "-X:foo" ...]})

Alex Miller (Clojure team) 2022-10-21T20:10:41.703149Z

we have a ticket for that already and eventually I'll get to it

cap10morgan 2022-10-21T20:11:00.253979Z

oh, ok. great!

Alex Miller (Clojure team) 2022-10-21T20:11:39.246859Z

https://clojure.atlassian.net/browse/TBUILD-6

👍 1
Alex Miller (Clojure team) 2022-10-21T20:12:26.453479Z

the issues outlined by Sean in the comments are tied up with other things and that's the main reason this doesn't exist yet

seancorfield 2022-10-21T20:52:15.497619Z

@cap10morgan We have a variant of the code from TBUILD-6 in our build.clj at work and it's pretty nasty so I would say, for now, using the -M style invocation for subprocesses is just so much easier.

👍 1
seancorfield 2022-10-21T20:54:11.109929Z

I haven't looked at Codox but I get the impression it expects to be run in the project's context (classpath etc) rather than as a separate tool? Codox would need to accept args to specify deps.edn files and aliases etc and then use t.d.a itself to build the basis and then walk all the code...

seancorfield 2022-10-21T20:54:41.282359Z

(which is why it's hard to run directly in-process in build.clj right?)

cap10morgan 2022-10-21T20:54:57.764749Z

yeah exactly

borkdude 2022-10-21T21:53:16.557769Z

It's also possible to start a clojure process using deps.clj

borkdude 2022-10-21T21:53:24.563669Z

which works as Clojure dependency as well, although it doesn't really have a nice Clojure API:

(borkdude.deps/-main "-Sdeps" <deps-map>" "-M" "-e" ...)

👍 1
Alex Miller (Clojure team) 2022-10-21T20:00:19.771109Z

for things that plan to shell out or manipulate basis information, then probably yes (or accept the same basis modifying parameters used throughout the :deps programs and pass those along to create-basis)