Enforce JDK 21+ as minimum build JDK for multi-release JAR support#22608
Enforce JDK 21+ as minimum build JDK for multi-release JAR support#22608Croway merged 2 commits intoapache:mainfrom
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
d9c5a9b to
eaf5e31
Compare
eaf5e31 to
69f7e24
Compare
apupier
left a comment
There was a problem hiding this comment.
- Change
Jenkinsfile.deploydefault JDK fromjdk_17_latesttojdk_21_latest
this mentioned change in the description is missing from the effectively modified files
|
ℹ️ CI did not run targeted module tests (root project files changed). |
removed, on main it was already done |
gnodet
left a comment
There was a problem hiding this comment.
Thanks for working on this, @Croway — the motivation is solid and ensuring SNAPSHOTs include the virtual thread classes is a real improvement.
A few suggestions, mostly around wording accuracy and one minor observation about the enforcer bypass scope. Nothing blocking.
Claude Code on behalf of Guillaume Nodet
| <rules> | ||
| <requireJavaVersion> | ||
| <version>[21,)</version> | ||
| <message>JDK 21+ is required to build Apache Camel. The multi-release JAR in camel-util requires JDK 21+ to compile virtual thread support. Building with JDK 17 produces JARs without virtual thread support.</message> |
There was a problem hiding this comment.
The "multi-release JAR" framing is a bit misleading — multi-release JARs are a Java 9 feature and work fine with older JDKs. What actually requires JDK 21 is the JDK 21-specific source code (virtual thread classes). The java-21-sources profile in camel-util/pom.xml activates on <jdk>[21,)</jdk> to compile those classes — it's the content, not the mechanism.
| <message>JDK 21+ is required to build Apache Camel. The multi-release JAR in camel-util requires JDK 21+ to compile virtual thread support. Building with JDK 17 produces JARs without virtual thread support.</message> | |
| <message>JDK 21+ is required to build Apache Camel. JDK 21-specific classes (e.g., virtual thread support in camel-util) are only compiled with JDK 21+. Building with JDK 17 silently omits these classes from the resulting JARs.</message> |
| include: | ||
| - java: '17' | ||
| # JDK 17 is kept for runtime compatibility testing. | ||
| # Skip the enforcer which requires JDK 21+ (needed for multi-release JAR compilation). |
There was a problem hiding this comment.
Same wording nit here:
| # Skip the enforcer which requires JDK 21+ (needed for multi-release JAR compilation). | |
| # Skip the enforcer which requires JDK 21+ (needed to compile JDK 21-specific classes). |
| - java: '17' | ||
| # JDK 17 is kept for runtime compatibility testing. | ||
| # Skip the enforcer which requires JDK 21+ (needed for multi-release JAR compilation). | ||
| maven_extra_args: '-Denforcer.phase=none' |
There was a problem hiding this comment.
Note: -Denforcer.phase=none disables all enforcer rules on the JDK 17 build, not just the Java version check — this also skips the Maven version check (>= 3.9.6) and the banned-dependencies check. These are still verified on the JDK 21 leg, so it's not a gap in practice, but worth being aware of.
If you wanted a narrower bypass, the enforcer plugin doesn't support per-execution skip properties out of the box, so this is probably the simplest approach.
| <maven.compiler.target>${jdk.version}</maven.compiler.target> | ||
| <maven.compiler.release>${jdk.version}</maven.compiler.release> | ||
| <minimalJavaBuildVersion>${jdk.version}</minimalJavaBuildVersion> | ||
| <minimalJavaBuildVersion>21</minimalJavaBuildVersion> |
There was a problem hiding this comment.
Minor: this property is likely used by the ASF parent POM's own requireJavaVersion rule in the enforce-java-version execution. Combined with the explicit requireJavaVersion rule you're adding below (lines 200–203), the enforcer may evaluate two requireJavaVersion checks — both requiring JDK 21. Not harmful, but redundant.
You could either:
- Just update this property (and rely on the parent POM's rule), or
- Keep the explicit rule with the custom message and leave this property at
${jdk.version}(since the explicit rule supersedes it anyway).
Either way works — just a heads-up.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
69f7e24 to
2d19c74
Compare
Summary
requireJavaVersion [21,)to the existingenforce-java-versionexecution inmaven-enforcer-pluginminimalJavaBuildVersionfrom${jdk.version}(17) to21Motivation
camel-utiluses multi-release JARs with ajava-21-sourcesprofile activated by<jdk>[21,)</jdk>. If Camel is built with JDK 17, the virtual thread classes underMETA-INF/versions/21/are silently omitted — users running on JDK 21 would get JARs without virtual thread support.Jenkinsfile.deploydefaults tojdk_17_latest, meaning daily SNAPSHOT deployments were built without virtual thread support.This does not change the runtime requirement — Camel JARs remain Java 17 compatible. It only ensures the build JDK is high enough to compile the multi-release JAR layers.
The enforcer runs only when the
fullprofile is active (not with-Dquickly), so fast local builds are unaffected. TheJenkinsfile.deployfix ensures SNAPSHOT deployments use JDK 21.Discussion thread: dev@camel.apache.org "Enforce JDK 21+ for building Camel"