I wonder if someone can spot my stupid mistake? I've got a mixed Java/Clojure library that I'm trying to convert to tools.build. I'm struggling to get the Clojure to AOT compile -- it doesn't seem to have the class files from the prior Java compilation step on the classpath. I've distilled the issue into this tiny sample project: https://github.com/scarytom/tbs Any feedback gratefully received.
running clj -T:build compile yields:
Unexpected error (ClassNotFoundException) macroexpanding gen-class at (com/scarytom/tbs/java_interop.clj:5:1).
java.lang.BeatBoxreading that back, it looks like it has the wrong package for BeatBox... that gives me a thread to pull on
com.scarytom.tbs.BeatBox is what i would expect to look for, not java.lang.BeatBox
(:import [com.scarytom.tbs BeatBox]) should be (:import com.scarytom.tbs.BeatBox)
thanks
did that work?
Sorry. I got called away. I'll try it out momentarily
no, your change doesn't work -- the space is correct for a java import.
The problem is that gen-class needs a fully qualified type for the return type of the makeBeatBox fn. I didn't know this.
I've checked in a working version, so you can see what I did.
thanks again for looking at this
You need to add the output "target/java-classes" where the compiled classfiles are written to the classpath of the clojure compile step
I would consider using them same directory for the output of both steps, which will solve it because the output of the clojure compile goes on the classpath anyway
thanks @hiredman -- I had already done that (`target/java-classes` is specified as a path in deps.edn). I wasn't aware that the output of the clojure compile is on the classpath for the clojure compile... that seems somewhat circular.
I suspect compile-clj doesn't use paths from deps.edn
curious @hiredman, as my sample project is compiling fine despite the clojure depending on a Java interface.
The basis is also passed to java-command, so it must merge stuff from there with the cp entry