Thursday, 23 November 2017

How to enforce specific JDK for a Maven build

As you maybe aware, the Maven enforcer plugin provides the option to enforce specific rules while building a project. For instance we could enforce a specific version of JDK to be used for a build.

For instance, let us enforce the usage of JDK 1.8.0. In that case, check the configuration of maven-enforcer-plugin in your main parent POM

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<rules>
<requireJavaVersion>
                  <version>1.8.0</version>
                </requireJavaVersion>
</rules>
</configuration>
</plugin>

Note the <requireJavaVersion> tag used for the same. For more information, check the following link as well.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker