Reputation: 2101
I a new "mavenist"... :-)
I work with Eclipse Mars.
I created a default maven project, and it uses JDK 1.5 by default. I would like to use 1.8.31 instead.
My current POM shows the following:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
On apache maven website I read that I need to change\replace it to something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable><!-- path-to-javac --></executable>
<compilerVersion>1.8.31</compilerVersion>
</configuration>
</plugin>
Thank you!
Upvotes: 1
Views: 2415
Reputation: 51711
You're on the right track but just override the options that you need to.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
...
</plugins>
</build>
Repeating verbose, fork, executable etc. isn't required.
Upvotes: 3
Reputation: 351
This should be enough, taken from my very recent project.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Upvotes: 2