Fork me on GitHub
#tools-deps
<
2022-12-15
>
mkvlr10:12:15

is it possible when creating a basis for a jar to exclude a dependency and if so, how? Tried manually fiddling with the generated basis but that was tedious and seemed error-prone.

Alex Miller (Clojure team)13:12:52

What does “for a jar” mean? Is this in tools.build context?

mkvlr13:12:11

yep, in tools.build

Alex Miller (Clojure team)13:12:55

Is this a top level dep or a dependency?

mkvlr13:12:06

top-level

Alex Miller (Clojure team)13:12:31

If top, you could I think add an :extra {the/lib nil} in the basis opts

mkvlr13:12:59

I’ll try this, thanks!

Alex Miller (Clojure team)13:12:49

Or if modifying the basis after, the critical part is the :libs and you could just remove the lib from that map

mkvlr13:12:12

like this?

(b/create-basis {:project "deps.edn" :extra {'io.github.nextjournal/dejavu nil}})

mkvlr13:12:34

still seeing a warning

mkvlr13:12:08

clj -T:build jar
Producing jar: target/clerk-0.12.707.jar
Skipping coordinate: {:git/sha 31bdc12d78d3a8f48cbd6c3df5b8c79ca88df4f1, :git/url , :deps/manifest :deps, :deps/root /Users/mk/.gitlibs/libs/io.github.nextjournal/dejavu/31bdc12d78d3a8f48cbd6c3df5b8c79ca88df4f1, :parents #{[]}, :paths [/Users/mk/.gitlibs/libs/io.github.nextjournal/dejavu/31bdc12d78d3a8f48cbd6c3df5b8c79ca88df4f1/src]}

borkdude13:12:33

Should it be {:extra {:deps ...}}?

borkdude13:12:51

We tried that and it says: expected map, got nil :)

mkvlr13:12:03

yeah getting `Bad coordinate for library io.github.nextjournal/dejavu, expected map: nil

mkvlr13:12:36

(def basis (-> (b/create-basis {:project "deps.edn"})
               (update :libs dissoc 'io.github.nextjournal/dejavu)))

borkdude13:12:37

dissocing from libs seems to work..

mkvlr13:12:39

that seems to do it

mkvlr13:12:08

yep, warning is gone, thanks!

Alex Miller (Clojure team)13:12:47

Deps is really a compositional model so excluding things is a lot harder than including them. I thought I had something for the above in there but I guess not. I assume this isnt a dep that could optionally be included rather than excluded?

mkvlr13:12:28

in that case I want to have it be there when consumed at as git dep but leave it out when I build the jar

borkdude13:12:45

This is a dependency that does some stuff at startup when in local dev or as a git dep, but as a mvn jar we would like to not use it since we can pre-compute what this lib is doing and also exclude the deps

Alex Miller (Clojure team)13:12:45

Well I’ll think about better ways to do that

🙏 2
pez12:12:49

add-lib3 doesn't work if you are using lein-tools-deps. Just logging that here so that it can be found using a search. 😃 I spent way too much time trying to figure out what was going on. The symptoms were that I got an error complaining that the jar wasn't found. If I download it to my .m2 directory, it works adding it, so it seems to be the download that does not happen.