Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnforceBytecodeVersion fails with "Restricted to JDK 11 yet […] contains […] targeted to JDK 17" (second try) #583

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

basil
Copy link
Member

@basil basil commented Feb 22, 2024

See #582 (comment); the previous fix was not tested properly and did not actually work. I tried for several hours to figure out how to update the Enforcer configuration from a different mojo but failed. Things I tried:

  • Looking up the plugin from the model and munging the XML programmatically (did not work, as the MojoExecution object uses a different copy of the XML)
  • Trying to configure Enforcer with the enforcer.rules Maven property (did not work, as that property does not support rules that take parameters)
  • Trying to munge the XML in the Enforcer MojoExecution programmatically from the validate MojoExecution (could not find a Maven API to do this)

Having run out of options, I decided to skip the enforceBytecodeVersion on the first invocation. I confirmed it works on the second invocation (using the profile activated by the marker file written in the first invocation).

Testing done

Built Jenkins core with -Dmaven.compiler.release=17 and built Text Finder with that core and these changes, after running git clean -fxd.

Before this PR, Enforcer failed on the first invocation. After this PR, the first invocation prints:

[INFO] --- maven-hpi-plugin:3.53-SNAPSHOT:validate (default-validate) @ text-finder ---
[INFO] Created marker file /home/basil/src/jenkinsci/text-finder-plugin/target/java-level/17
[INFO] Setting maven.compiler.release to 17
[INFO] Setting maven.compiler.testRelease to 17
[WARNING] Skipping enforceBytecodeVersion; will run on next invocation.
[INFO] 
[INFO] --- maven-hpi-plugin:3.53-SNAPSHOT:validate-hpi (default-validate-hpi) @ text-finder ---
[INFO] 
[INFO] --- maven-enforcer-plugin:3.4.1:enforce (display-info) @ text-finder ---
[INFO] Rule 0: io.jenkins.tools.incrementals.enforcer.RequireExtensionVersion passed
[INFO] Rule 1: org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
[INFO] Rule 2: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
[INFO] Rule 3: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
[INFO] Rule 4: org.apache.maven.enforcer.rules.dependency.RequireUpperBoundDeps passed

and the second invocation prints

[INFO] --- maven-hpi-plugin:3.53-SNAPSHOT:validate (default-validate) @ text-finder ---
[INFO] Created marker file /home/basil/src/jenkinsci/text-finder-plugin/target/java-level/17
[INFO] 
[INFO] --- maven-hpi-plugin:3.53-SNAPSHOT:validate-hpi (default-validate-hpi) @ text-finder ---
[INFO] 
[INFO] --- maven-enforcer-plugin:3.4.1:enforce (display-info) @ text-finder ---
[INFO] Rule 0: io.jenkins.tools.incrementals.enforcer.RequireExtensionVersion passed
[INFO] Rule 1: org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
[INFO] Rule 2: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
[INFO] Rule 3: org.codehaus.mojo.extraenforcer.dependencies.EnforceBytecodeVersion passed
[INFO] Rule 4: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
[INFO] Rule 5: org.apache.maven.enforcer.rules.dependency.RequireUpperBoundDeps passed

…tains […] targeted to JDK 17" (second try)
@basil basil added the bug label Feb 22, 2024
@basil basil requested a review from Vlatombe February 22, 2024 16:52
@basil basil merged commit f0d440d into jenkinsci:master Feb 23, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant