talios / clojure-maven-plugin

Apache Maven Mojo for compiling clojure scripts to class files
252 stars 74 forks source link

compiler mojo does not respect JAVA_HOME when searching for executable #109

Closed tsachev closed 5 years ago

tsachev commented 6 years ago

Currently the only why to tell the clojure compiler which java executable to use is to put it on the class path or use maven toolchains.

if my path points to a java that I do not want to use for some reason (say java 9), I want to be able to run maven with for e.g.

JAVA_HOME=/path/to/jdk8 mvn clean verify

This will run maven with the java 8, but the clojure compiler with java 9.

Another option would be to have a javaHome property in the compiler mojo that I could set with -D like

JAVA_HOME=/path/to/jdk8 mvn clean verify -Dclojure.javaHome=/path/to/jdk8
gseyffert commented 5 years ago

This is biting me right now too. Maven is compiling under JDK 11, configured via JAVA_HOME, but my default runtime is Java 8 and that's what clojure-maven-plugin is picking up. Everything compiles fine, but then any call into Clojure code blows up at runtime with IncompatibleClassChangeError errors due to byte code incompatibility.

talios commented 5 years ago

All being well a new release should be winging its way out tonight:

env JAVA_HOME=/Users/amrk/Applications/jdk-12+33/Contents/Home \
    mvn com.theoryinpractise:clojure-maven-plugin:compile -X

now yields:

[DEBUG] Command line: [/Users/amrk/Applications/jdk-12+33/Contents/Home/bin/java, \
-Dclojure.compile.path=/var/folders/2h/76nn14b502q410szcd74lv200000gn/T/classes662961663364622820.dir, -jar, .....
gseyffert commented 5 years ago

Awesome!! Thank you for the quick fix here.