Fork me on GitHub
#tools-build
<
2023-03-29
>
mpenet06:03:38

I have a case with multiple "modules" in a repo, each with its own deps.edn, pointing to each other via deps local/root "../foo/" (so there can be multiple levels of deps of that kind, foo can depend on another module the same way), so far so good. It works for most things, until I try to build a jar (with some fairly common b/write-pom b/copy-dir etc b/jar. That jar loose any traces of the local/root deps sources (they are in basis but not included in the jar in any form). Maybe it's expected, maybe not, not sure. I could imagine the src of these would be included and their deps expanded to look for other local/root mentions.

mpenet06:03:37

I suppose one could do that work at jar creation time but since it works transparently for git deps I could imagine it should also for local/root deps

Alex Miller (Clojure team)12:03:40

Can you be more specific about what “doesn’t work”?

mpenet12:03:37

the source files of dependencies using local/root coords are not included in the jar

Alex Miller (Clojure team)12:03:10

That seems normal - usually you only have your own sources in a jar you make unless it’s an uberjar

mpenet12:03:01

if you build a jar from local/root deps you'd expect them to be "included" as they will bever be resolved

Alex Miller (Clojure team)12:03:39

Well, your expectations may vary from mine :)

Alex Miller (Clojure team)12:03:49

But, as Sean has done apparently, you have the tools to identify the paths for local deps from the basis and the means to copy their sources into a jar making location

mpenet12:03:38

yes we do something like that currently, but I suppose that could be built'in (via an option to local/root maybe)

mpenet12:03:07

We're not the first and likely not the last ones to hit that issue

Alex Miller (Clojure team)12:03:34

Feel free to file a request on ask Clojure, but it is not going to be at the top of my list for a while

mpenet12:03:26

I think at the very least a documentation update about this wouldn't hurt

mpenet12:03:44

I mean on the guide

Alex Miller (Clojure team)12:03:29

clojure-site is available for issues and prs…

Alex Miller (Clojure team)13:03:05

you said at the top that this "transparently works for git deps" but I don't think that's true. it should work (for both) in uber

seancorfield15:03:15

FWIW, depstar used to rely on (:classpath-roots basis) to find directories to copy into the uberjar.

mpenet18:03:46

I adapted what you did in build-clj to our jar fn. it seems to work

mpenet18:03:52

Do you still rely on something like that with your current setup?

seancorfield18:03:33

No, as I said earlier, we use AOT and rely on transitive compilation to pull code into our uberjars. We do not build library JARs at work.

mpenet18:03:46

Oh ok. That’d be the ideal solution (not building lib jars), unfortunately not all consumers of our internal libs are on t.deps yet

mpenet07:03:06

it seems @seancorfield hit that one in the past, I might just take the same approach/workaround

seancorfield15:03:34

Since compile is transitive, we rely on that to compile all the :local/root stuff into the project's classes dir, to be bundled up into the uberjar: we don't bother with source in the uberjar -- and we don't have any dynamic loading at runtime (of our own code, at least).

mpenet15:03:47

We don’t have an issue with uberjars

mpenet15:03:26

It’s solely a problem for libs depending on other libs with local root for us

mpenet15:03:03

So just jars as we still deploy them on our maven repo for now

seancorfield15:03:42

Ah, yeah, libs built with source deps are problematic because you want some source deps but not all source deps. As noted in the other thread, depstar used (:classpath-roots basis) to find source to copy in -- and only later added a :paths-only option to avoid copying in source deps for thin JAR files. It's deprecated/archived now but you can go look at the source to see what it did...

mpenet15:03:15

I ll have a look