Skip to content

Commit

Permalink
EnforceBytecodeVersion fails with "Restricted to JDK 11 yet […] con…
Browse files Browse the repository at this point in the history
…tains […] targeted to JDK 17" (second try) (#583)
  • Loading branch information
basil committed Feb 23, 2024
1 parent e47a848 commit f0d440d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,20 @@ public void execute() throws MojoExecutionException {
throw new MojoExecutionException("Java " + javaVersion + " or later is necessary to build this plugin.");
}
writeProfileMarker(javaVersion);
setProperty("maven.compiler.release", Integer.toString(javaVersion.toReleaseVersion()));
setProperty("maven.compiler.testRelease", Integer.toString(javaVersion.toReleaseVersion()));
if (!project.getProperties()
.getProperty("maven.compiler.release")
.equals(Integer.toString(javaVersion.toReleaseVersion()))) {
// Apply the profile to the in-memory model.
setProperty("maven.compiler.release", Integer.toString(javaVersion.toReleaseVersion()));
setProperty("maven.compiler.testRelease", Integer.toString(javaVersion.toReleaseVersion()));

// Unfortunately, I see no way to update the Enforcer configuration without restarting Maven.
// In the meantime, skip this rule in the current invocation to avoid a false positive.
if (!project.getProperties().containsKey("enforcer.skipRules")) {
getLog().warn("Skipping enforceBytecodeVersion; will run on next invocation.");
project.getProperties().setProperty("enforcer.skipRules", "enforceBytecodeVersion");
}
}

if (new VersionNumber(findJenkinsVersion()).compareTo(new VersionNumber("2.361")) < 0) {
throw new MojoExecutionException("This version of maven-hpi-plugin requires Jenkins 2.361 or later");
Expand Down

0 comments on commit f0d440d

Please sign in to comment.