I have been searching for a solution to my Maven and Eclipse JRE version issue, where JRE 1.5 is being forced in the Eclipse project somehow even when I want different.
During my searches, I have noticed that there appear to be two different solutions to this. The first solution suggests using something like the snippet below
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
The second solution suggests using just two properties:
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
Why are the two possible solutions and why do they differ?
There's a long way to specify it (by defining a <plugin> configuration in your pom file), which is the normal way to configure plugins, and there is a shorthand using a user property.
As you can find in the documentation.
The -source argument for the Java compiler. Default value is: 1.5.
User property is: maven.compiler.source.
If you only want to specify the source and target level, then there is no difference, but the <plugin> configuration also allows you to specify other configuration settings, restrict the versions of the compiler plugin, etc.
Many Maven plugins allow to use some properties to specify the parameters. The maven.compiler.source and maven.compiler.target properties are specified by the Maven Compiler Plugin.
See the "User Property" sections:
http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#source
http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#target
http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With