Fork me on GitHub
#tools-build
<
2022-10-21
>
cap10morgan15:10:22

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)16:10:29

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

Alex Miller (Clojure team)16:10:09

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

cap10morgan16:10:27

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)16:10:27

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

cap10morgan16:10:28

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)16:10:12

yeah, it intentionally does not

👍 1
Alex Miller (Clojure team)16:10:03

"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)16:10:43

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

cap10morgan16:10:58

gotcha. makes sense. thanks!

cap10morgan17:10:09

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

cap10morgan17:10:49

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

Alex Miller (Clojure team)17:10:13

I’m not understanding that

Alex Miller (Clojure team)17:10:57

You might need to add the :deps too

cap10morgan17:10:08

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)17:10:05

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

cap10morgan17:10:34

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

cap10morgan17:10:22

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

cap10morgan17:10:32

(Maybe I will, that is)

borkdude18:10:42

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

cap10morgan18:10:11

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

Alex Miller (Clojure team)16:10:08

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

cap10morgan19:10:14

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)19:10:43

I think unhelpfully I will say it depends :)

Alex Miller (Clojure team)19:10:22

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

cap10morgan20:10:34

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

cap10morgan20:10:07

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)20:10:41

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

cap10morgan20:10:00

oh, ok. great!

Alex Miller (Clojure team)20:10:26

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

seancorfield20:10:15

@U06FS3DLH 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
seancorfield20:10:11

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

seancorfield20:10:41

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

borkdude21:10:16

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

borkdude21:10:24

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)20:10:19

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)