gradle-clojure
gradle-clojure copied to clipboard
Fails to produce class file for namespaces marked with (:gen-class)...
The short form: setting the aotCompile to true causes my app to die with an exception complaining that "clojure.pprint.proxy$java.io.Writer$IDeref$PrettyFlush$4923d848 cannot be cast to clojure.pprint.PrettyFlush".
After some googling, I turned up this. The summary: it seems like aot-compiling clojure.pprint is a bad idea, due to some classloader stuff happening in 1.8 or better.
So I tried removing the aotCompile flag, and I have the namespace containing my -main method marked with (:gen-class) but no class file is generated for it. This means I can't set the Main-Class metadata for the jar and have it execute my application automatically.
Is this expected behavior? Is there a better way to go about getting what I want? I had to drop back to Clojure 1.7.0 for the moment, since it doesn't suffer from the issue, but that's not a good long-term tactic. :-)
I should mention that this isn't critical, but we are testing driving your plugin to see how well it works with Gradle. Outside of this issue, there's been no troubles.
Perhaps the approach taken here is not entirely wrong (though I think :gen-class should still generate the class). There's some interesting discussion around mixed AOT-compilation and JIT compilation here: http://dev.clojure.org/jira/browse/CLJ-1544
Right, this is complicated. See here for some recent discussion on mixing AOT and non-AOT code. I'm not sure what the right answer is. I actually hadn't considered this case, I'd assumed that users would either AOT compile or not. If partially AOT compiling is actually a requirement, I'd have to think about how the config for that would work.
Yeah, I saw that conversation, which led me to the ticket. It definitely seems complicated. OTOH, I was suprised :gen-class didn't work as expected. I didn't expect that you would have to do anything special and the compiler would pick it up and do the right thing. :-(
At any rate, there actually two problems: this one (class files not being generated for namespaces marked with :gen-class), and the fact that aot compilation seems to be broken in someway for certain code. I was originally thinking that maybe clojure.pprint just didn't like to be AOT compiled, but it appears that's not entirely the case. Things work under Leiningen, but not under Gradle. I'll file a separate ticket for that issue.