Fork me on GitHub
#leiningen
<
2022-10-23
>
Tomasz Kontusz11:10:39

I have a problem with lein javac that I don't know how to approach: I've made a user.clj with some repl helpers, which imports my main application. This application uses a few Java classes. When the classes are already compiled, I can run lein javac. When I remove the classes then lein javac crashes with ClassNotFoundException when importing my main namespace. When I comment out all code in my user.clj it works again.

Tomasz Kontusz11:10:26

Is leiningen always loading the user namespace? I've assumed it's only used for the REPL, am I wrong?

vemv11:10:06

Clojure always loads user.clj (before anything else!) if it is in your classpath

vemv11:10:22

it has that special semantic

vemv11:10:53

assuming that user.clj resides in dev/ which is added by a :dev profile, you could run: lein with-profile -dev javac ...that's meant to be effectively equivalent to "commenting out user.clj" :)

Tomasz Kontusz11:10:31

Oh, that makes sense! I'll move my repl tools to another namespace, user.clj is just not the right place for them.

👍 1
vemv11:10:26

yeah I have them in dev/dev.clj

Tomasz Kontusz11:10:44

Thank you! I was starting to doubt my senses (the REPL would start sometimes, crash sometimes, or my favourit: Cursive would hang on something like "Calculating Classpath")

clojure-spin 1
vemv11:10:44

...this "special semantic" has all sorts of unintended side-effects 🙃