Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AOT compiled clojure code in Java #85

Open
ishan opened this issue Jul 4, 2014 · 2 comments
Open

Use AOT compiled clojure code in Java #85

ishan opened this issue Jul 4, 2014 · 2 comments

Comments

@ishan
Copy link

ishan commented Jul 4, 2014

Currently, even with packaging specified as Clojure, the maven compiler plugin is run before clojure compiler plugin, making classes generated from clojure using :gen-class unavailable for linking.

Would it be possible to generate the clojure class files first and add them to the maven java compiler classpath when it is running?

@talios
Copy link
Owner

talios commented Jul 4, 2014

...and then the Java classes won't be able to refer to the clojure. Catch22.

If you add a <plugin> declaration for the maven-compiler-plugin after the clojure-maven-plugin it should, in theory run the clojure compilation first.

Does this work for you?

@ishan
Copy link
Author

ishan commented Jul 6, 2014

I agree it is a catch 22, but a thread reports something funny here:

Even if a java class that is needed is not present, the clojure class is generated (albeit with a warning/error). I looked at the compilation section on clojure's website, and looks like gen-class only generates a stub class, and the implementation is only compiled or linked at runtime.

I guess I am trying to hint towards this: Given the dynamic nature of clojure and the delayed compilation, it is possible to generate the :gen-class stub, not compile the clojure code without any warnings since the java code is not present but it is not really needed also, and then compile the java code that depends on the clojure gen-class.

My understand is limited here, but does clojure:compile goal AOT compile all the clojure code? I remember reading that mostly clojure code is submitted as source in jar and compiled at runtime.

Adding maven-compiler-plugin after clojure-maven-plugin doesn't work since maven-compiler-plugin binds automatically to the compile phase when packaging is jar or clojure and always comes first somehow. The only option is to change packing to pom and then this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants