kaocha

gleisonsilva 2022-09-09T19:00:03.812149Z

hey all

gleisonsilva 2022-09-09T19:00:12.711839Z

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

gleisonsilva 2022-09-09T19:00:25.430279Z

when I do a "jar" it all works fine

gleisonsilva 2022-09-09T19:00:44.704779Z

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

gleisonsilva 2022-09-09T19:01:22.288839Z

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

gleisonsilva 2022-09-09T19:23:42.208439Z

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

gleisonsilva 2022-09-09T19:24:16.037539Z

the test ns still complains:

gleisonsilva 2022-09-09T19:24:33.206459Z

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

plexus 2022-09-09T20:18:19.763149Z

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)

plexus 2022-09-09T20:18:52.637259Z

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

plexus 2022-09-09T20:20:31.525789Z

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.

plexus 2022-09-09T20:21:15.640059Z

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.

gleisonsilva 2022-09-09T20:54:13.318729Z

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.