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.
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
Can you be more specific about what “doesn’t work”?
the source files of dependencies using local/root coords are not included in the jar
this leads to workarounds such as https://github.com/seancorfield/build-clj/blob/main/src/org/corfield/build.clj#L185-L189
That seems normal - usually you only have your own sources in a jar you make unless it’s an uberjar
if you build a jar from local/root deps you'd expect them to be "included" as they will bever be resolved
Well, your expectations may vary from mine :)
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
yes we do something like that currently, but I suppose that could be built'in (via an option to local/root maybe)
We're not the first and likely not the last ones to hit that issue
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
I think at the very least a documentation update about this wouldn't hurt
I mean on the guide
clojure-site is available for issues and prs…
right
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
FWIW, depstar used to rely on (:classpath-roots basis) to find directories to copy into the uberjar.
I adapted what you did in build-clj to our jar fn. it seems to work
Do you still rely on something like that with your current setup?
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.
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
it seems @seancorfield hit that one in the past, I might just take the same approach/workaround
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).
We don’t have an issue with uberjars
It’s solely a problem for libs depending on other libs with local root for us
So just jars as we still deploy them on our maven repo for now
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...
I ll have a look
Thanks