Fork me on GitHub
#kaocha
<
2022-09-09
>
gleisonsilva19:09:12

I've this namespace where (:gen-class) has been used

gleisonsilva19:09:25

when I do a "jar" it all works fine

gleisonsilva19:09:44

then i have this "test" where I do need to load a .class

gleisonsilva19:09:22

but i'm not figuring out how the tests can trigger the proper compilation for generating the class

gleisonsilva19:09:42

I've tried already build the .jar and put the reference to it using :local/root in :test { :extra-paths ... } but yet no have success

gleisonsilva19:09:16

the test ns still complains:

gleisonsilva19:09:33

java.lang.ClassNotFoundException: mynamespace.core.class at http://java.net.URLClassLoader.findClass (URLClassLoader.java:471)

plexus20:09:19

That should work... You need to somehow get the compiled .class file onto the class path. I would check that the jar actually contains the right file at the right location (use any tool that understands zip files to look at the jar)

plexus20:09:52

You also don't really need the jar as such, you should be able to use clojure.core/compile on your gen-class namespace

plexus20:09:31

I always have to look up how to tell it where the compilation goes. I believe there's a dynamic var for that. I think it defaults to target, and if that directory doesn't exist you get a completely unhelpful error message, but once you figure that out it's pretty straightforward. It's something you can do in a hook.

plexus20:09:15

On my phone now and it's almost bedtime here but I can put together an example. Feel free to remind me if I don't get to it in the next few days.

gleisonsilva20:09:13

Hi, @plexus! Tks for your reply! After some try and error I've manage to get it working using the .jar (in deps.edn :test {:extra-paths ...} i've added a reference to :root/local ..jar and it's working now. But I do want to figure out a more fast way to test, as, right now, i'm having to generate the .jar after each change and then be able to test... very slow workflow... I'll be very thankfull if you can point me some alternative way.