tools-build

mpenet 2023-03-29T06:11:38.049839Z

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.

mpenet 2023-03-29T06:12:37.234639Z

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) 2023-03-29T12:35:40.662359Z

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

mpenet 2023-03-29T12:36:37.881299Z

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

mpenet 2023-03-29T12:38:08.538739Z

this leads to workarounds such as https://github.com/seancorfield/build-clj/blob/main/src/org/corfield/build.clj#L185-L189

Alex Miller (Clojure team) 2023-03-29T12:38:10.046329Z

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

mpenet 2023-03-29T12:39:01.910909Z

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) 2023-03-29T12:39:39.678029Z

Well, your expectations may vary from mine :)

Alex Miller (Clojure team) 2023-03-29T12:40:49.319269Z

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

mpenet 2023-03-29T12:41:38.531699Z

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

mpenet 2023-03-29T12:42:07.820059Z

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

Alex Miller (Clojure team) 2023-03-29T12:42:34.040009Z

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

mpenet 2023-03-29T12:44:26.990419Z

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

mpenet 2023-03-29T12:44:44.664249Z

I mean on the guide

Alex Miller (Clojure team) 2023-03-29T12:45:29.496779Z

clojure-site is available for issues and prs…

mpenet 2023-03-29T12:45:40.681569Z

right

Alex Miller (Clojure team) 2023-03-29T13:24:05.806029Z

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

seancorfield 2023-03-29T15:23:15.610129Z

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

mpenet 2023-03-29T18:01:46.322029Z

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

mpenet 2023-03-29T18:02:52.575929Z

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

seancorfield 2023-03-29T18:03:33.805219Z

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.

mpenet 2023-03-29T18:04:46.911479Z

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

mpenet 2023-03-29T07:52:06.598489Z

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

seancorfield 2023-03-29T15:15:34.405399Z

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

mpenet 2023-03-29T15:30:47.692829Z

We don’t have an issue with uberjars

mpenet 2023-03-29T15:31:26.316959Z

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

mpenet 2023-03-29T15:32:03.781819Z

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

seancorfield 2023-03-29T15:43:42.056869Z

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

mpenet 2023-03-29T15:45:15.129229Z

I ll have a look

mpenet 2023-03-29T15:45:18.903659Z

Thanks