Suppose I have a multi-module Maven project, with two modules:
foo
; requires Java 1.8 to compilebar
; requires Java 11 to compile
I'd like to be able to build these by running mvn clean install
from the parent directory and have them compile using the appropriate Java versions.
Let's be clear: upgrading both to Java 11 is a non-starter. Why:
- I want to upgrade application
bar
to Java 11 to get the latest features and improvements of the Java language.bar
is a standalone Spring Boot application and I am able to do that. - Application
foo
is a JBoss deployment module plugin. It's plugged in to a third-party app that at present is on Java 8. I cannot drop a module compiled in Java 11 into an app running in Java 8.
I see that there is a way to do this using the maven-toolchains-plugin as described in this post. That could work. But I use jenv
to manage versions, and it's possible to set the Java version per directory (using jenv local
). I'm wondering if there is a way to use Jenv to do this instead of the toolchains plugin. It does just about everything I need; I just need to figure out how to get Maven to read the Java version from the jenv config file in the directory.