Mark Mark - 1 month ago 14
Java Question

maven-assembly-plugin and JVM version

is it possibile to create a JAR using the

maven-assembly-plugin
, setting a specific compiler version?

Thanks

UPDATE:

I meant to say:
maven-compiler-plugin

Answer

You can not really set the compiler version (as maven uses what's installed), but you can configure source and target level on the maven-compiler-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.5.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin> 

Edit: As khmarbaise points out in the comments, you can specify a different compiler, if you must, but you will have to set fork to true and specify the path to the executable, which, in the usual case, is not the kind of complication that you'd want. But he's right nonetheless, it's actually possible, and apparently has been since version 2.0 of the maven compiler plugin.

Comments