Skip to content

Conversation

@mattrpav
Copy link
Contributor

@mattrpav mattrpav commented Nov 11, 2025

I tested building with JDK 21 and then running with JDK 17 without a problem.

The docs for enforcer plugin make it read that this setting impacts runtime, but it does not in fact change the compiler-plugin values used for source/target/release.

NOTE: This needs to be merged into main after main is updated to 6.3.0-SNAPSHOT

@mattrpav mattrpav self-assigned this Nov 11, 2025
@gemmellr
Copy link
Member

The java version rule is just about the JVM running the enforcement, i.e the current runtime. It has nothing to do with the compiler settings or what the build output compiles for / runs on, which is all independent.

Wasnt the idea to only require release builds are done with JDK 21+? This change also prevents building testing on 17+, which would ideally still be a thing if supporting/targeting it?

@mattrpav
Copy link
Contributor Author

mattrpav commented Nov 11, 2025

@gemmellr good catch. I'll move this change inside the apache-release profile (edited for exact profile name)

@mattrpav mattrpav force-pushed the NO-JIRA-enforcer-jdk-21 branch from 8666755 to ff3fed9 Compare November 12, 2025 14:54
@mattrpav
Copy link
Contributor Author

Output when building with JDK 17 and apache-release profile

% mvn -Papache-release clean install -DskipTests=true
...
[ERROR] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message:
[ERROR] You must use Java 21+ to release.

@jbonofre jbonofre self-requested a review November 12, 2025 15:02
@mattrpav mattrpav changed the title [NO-JIRA] Update enforcer-plugin to require building with JDK 21 [NO-JIRA] Update enforcer-plugin to releasing with JDK 21 Nov 12, 2025
Copy link
Member

@jbonofre jbonofre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me for the enforcer.

However, if we merge it, it means Jenkins will fail. I suggest to update Jenkinsfile as part of this PR.

<configuration>
<rules>
<requireMavenVersion>
<version>3.0.5</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maven 3.0.x doesn't support JDK21.
I suggest to set Maven to 3.9.11.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd definitely use something much newer than 3.0.5 since most current plugins dont work with versions that old (baseline is 3.6.3 currently I think), though I probably wouldnt require 3.9.11 either (even though it is what I am now using) but perhaps some older 3.9.x.

@gemmellr
Copy link
Member

This change looks good to me for the enforcer.

However, if we merge it, it means Jenkins will fail. I suggest to update Jenkinsfile as part of this PR.

I dont see mention of it enabling the apache-release profile, so I dont think it will fail unless thats being introduced elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants