'Maven project with modules designed to run on different JDK [closed]

I have a project with one main module that use pom packaging and several submodules that are defined to use jar packaging. I want to have some of them ready to run on JDK7 and other for JDK8 (and eventually embed those for JDK7 as dependencies in the JDK8 counterpart).

The goal is to release the submodules as independent jars (e.g. on Maven Central)

Is this approach correct? Any drawback?



Solution 1:[1]

There is absolutely nothing against doing that. However, if you have a module that needs compiling with Java 8, you need to make sure Maven is also launched with Java 8.

Then, you need to override the configuration of the maven-compiler-plugin for each module and define the correct Java version (<source> and <target> properties).

After that, you can use a Java 7 dependency in a Java 8 project without any problems.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tunaki