leiningen

jpalharini 2025-03-06T18:17:32.091549Z

Is it expected for Leiningen not to complain/warn about missing dependencies when building a JAR (not an uberjar)? I have a project that requires a namespace in another Clojure library, but that Clojure library is not a direct or transitive dependency (checked with lein deps :tree). lein uberjar fails, but lein jar doesn't.

👀 1
jpalharini 2025-03-07T13:03:05.685589Z

That makes sense. I just thought lein jar also did compilation.

2025-03-07T14:50:16.385159Z

It would do compilation if you were trying to AOT things. But that’s typically only done for uberjar.

seancorfield 2025-03-06T18:18:47.694179Z

lein jar just packages the specified code into a JAR. It doesn't load/compile it, so it wouldn't know about missing dependencies. Whatever you specify in :dependencies will get mapped into the pom.xml that's inside the JAR.

seancorfield 2025-03-06T18:20:04.787069Z

In Maven, I think you'd specify such dependencies as provided -- i.e., to indicate the user must provide them -- but I'm not sure if you can specify that in project.clj

seancorfield 2025-03-06T18:20:32.270519Z

(I haven't used lein for years, at this point, so I'm going on memory)

2025-03-06T19:27:01.940629Z

I think you can do it via something like a scope, but I think the main path is to use the special :provided profile mentioned in the docs: https://codeberg.org/leiningen/leiningen/src/commit/8cda41784545bef71d1d605d739f4935c8fe4f21/doc/PROFILES.md#default-profiles