This rule enforces certain Java JDK versions. The rule uses the Enforcer version range syntax to define allowed versions.
The following parameters are supported by this rule:
The JDK version is retrieved and the following processing occurs before being checked:
This preprocessing normalizes various JDK version strings into a standard x.y.z-b version number. Your required range should therefore use the x.y.z-b format for comparison. There is an easy way to see how your current JDK string will be normalized:
mvn enforcer:display-info ... [enforcer:display-info] Maven Version: 2.0.8 JDK Version: 1.5.0_11 normalized as: 1.5.0-11 OS Info: Arch: x86 Family: windows Name: windows xp Version: 5.1
Sample Plugin Configuration:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.6.0</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>If you would like to enforce a certain vendor string for the JDK, you would use the RequireProperty rule, and check the java.vendor property with a regular expression.