Fork me on GitHub
#leiningen
<
2022-10-21
>
souenzzo19:10:40

how do I get my "prod classpath" in lein? I'm using :test-paths ["test"] and when I run lein classpath it includes my test dir. This is not what I expect.

souenzzo19:10:41

Update: even without :test-paths ["test"], with a almost empy project.clj, it includes test in my lein classpath

vemv20:10:03

lein with-profile -user,-dev,-test classpath ?

vemv20:10:42

(I haven't tried it) I thiiiink the classpath command had some oddities that would make it still include stuff that shouldn't

souenzzo20:10:23

I would like to get "the classpath that will be used to create the uberjar"

souenzzo20:10:38

mostly for debug

vemv20:10:44

you could also add +uberjar to the mix (although it's quite rare to add deps only in the :uberjar profile)

vemv20:10:56

LMK if that command worked for you

souenzzo21:10:16

lein show-profiles shows every profile in the project After a lein with-profiles -auth,-base,-checkout,-debug,-default,-leiningen/default,-leiningen/test,-offline,-uberjar,-update,-user classpath | tr ':' '\n' | head (removing all profiles) it still prints "test" directory 😞

vemv23:10:34

...it's hardcoded. you can have a profile named blank-test-paths that does a :test-paths ^:replace []

colinkahn20:10:42

Is it correct to assume that if I have specified a version for a dependency defined in project.clj and multiple versions installed in ~/.m2 lein should pick the version I have specified? I ask because people on my team, myself included, have seen that installing a newer version of clojure.java-time in a project that depends on an earlier version ends up using the newer one (which is incompatible in our case).

souenzzo21:10:53

you can start a REPL and run this code

(for [i ["java_time/api.clj"
         "java_time/api.class"
         "java_time/api.cljc"]
      f (enumeration-seq
          (.getResources
            (.getContextClassLoader (Thread/currentThread))
            i))]
  (str f))
It should result in a list with 1 single element that starts with jar:file, and contains the java-time version

colinkahn23:10:02

@U2J4FRT2T thanks, it shows what I would expect, so I'll need to dig in deeper to understand what exactly is going on.

vemv23:10:59

lein deps :tree can help you in two ways: • show which other dep might be depending on the different clojure.java-time version • explictly inform you of such ambiguities (you can always ban them by setting :pedantic? :abort in your project I consider :pedantic? a basic tenet of a nicely maintained project :)

colinkahn23:10:06

This ended up being different behavior between java versions.

vemv04:10:58

really? I would say the JVM version doesn't affect maven dependency resolution

colinkahn16:10:54

It wasn't a dependency at all in the end, but changes in the resolution of the timestamps.

vemv16:10:00

got it, yeah it has bitten me before I would use JDK8 while my team / app JDK16 so I would get some surprising behavior :)