RequireJavaVersion extends AbstractVersionEnforcer { @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { String javaVersion = SystemUtils.JAVA_VERSION; Log log = helper.getLog(); log.debug( "Detected Java String: '" + javaVersion + "'" ); javaVersion = normalizeJDKVersion( javaVersion ); log.debug( "Normalized Java String: '" + javaVersion + "'" ); ArtifactVersion detectedJdkVersion = new DefaultArtifactVersion( javaVersion ); log.debug( "Parsed Version: Major: " + detectedJdkVersion.getMajorVersion() + " Minor: " + detectedJdkVersion.getMinorVersion() + " Incremental: " + detectedJdkVersion.getIncrementalVersion() + " Build: " + detectedJdkVersion.getBuildNumber() + " Qualifier: " + detectedJdkVersion.getQualifier() ); enforceVersion( helper.getLog(), "JDK", getVersion(), detectedJdkVersion ); }  @Override void execute( EnforcerRuleHelper helper ); static String normalizeJDKVersion( String theJdkVersion );  }
@Test @Ignore public void thisShouldNotCrash() throws EnforcerRuleException { RequireJavaVersion rule = new RequireJavaVersion(); rule.setVersion( SystemUtils.JAVA_VERSION ); EnforcerRuleHelper helper = EnforcerTestUtils.getHelper(); rule.execute( helper ); }