Skip to content

Require JDK 21 for building (but keep the Java 17 baseline) + fixes for toolchain support #10150

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
with:
persist-credentials: false
ref: ${{ github.ref }}
- name: Set up Java 17
- name: Set up JDK
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Generate cache key
id: cache-key
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
build:
permissions:
contents: read
name: OpenJDK 17 - ${{matrix.rdbms}}
name: OpenJDK 21 - ${{matrix.rdbms}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -55,11 +55,11 @@ jobs:
env:
RDBMS: ${{ matrix.rdbms }}
run: ci/database-start.sh
- name: Set up Java 17
- name: Set up Java 21
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Generate cache key
id: cache-key
Expand Down Expand Up @@ -253,11 +253,11 @@ jobs:
persist-credentials: false
- name: Reclaim disk space and sanitize user home
run: .github/ci-prerequisites-atlas.sh
- name: Set up Java 17
- name: Set up Java 21
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Generate cache key
id: cache-key
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
5 changes: 3 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
@Library('hibernate-jenkins-pipeline-helpers') _
import org.hibernate.jenkins.pipeline.helpers.job.JobHelper

@Field final String DEFAULT_JDK_VERSION = '17'
@Field final String DEFAULT_JDK_VERSION = '21'
@Field final String DEFAULT_JDK_TOOL = "OpenJDK ${DEFAULT_JDK_VERSION} Latest"
@Field final String NODE_PATTERN_BASE = 'Worker&&Containers'
@Field List<BuildEnvironment> environments
Expand All @@ -40,10 +40,11 @@ stage('Configure') {
// Don't build with HANA by default, but only do it nightly until we receive a 3rd instance
// new BuildEnvironment( dbName: 'hana_cloud', dbLockableResource: 'hana-cloud', dbLockResourceAsHost: true ),
new BuildEnvironment( node: 's390x' ),
// We build with JDK 21, but produce Java 17 bytecode, so we test with JDK 17, to be sure everything works.
new BuildEnvironment( testJdkVersion: '17' ),
// We want to enable preview features when testing newer builds of OpenJDK:
// even if we don't use these features, just enabling them can cause side effects
// and it's useful to test that.
new BuildEnvironment( testJdkVersion: '21', testJdkLauncherArgs: '--enable-preview' ),
new BuildEnvironment( testJdkVersion: '23', testJdkLauncherArgs: '--enable-preview' ),
new BuildEnvironment( testJdkVersion: '24', testJdkLauncherArgs: '--enable-preview' ),
// The following JDKs aren't supported by Hibernate ORM out-of-the box yet:
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ for its CI needs. See

== Building from sources

The build requires at least Java 11 and at most Java 17.
The build requires at least JDK 21, and produces Java 17 bytecode.

Hibernate uses https://gradle.org[Gradle] as its build tool. See the _Gradle Primer_ section below if you are new to
Gradle.
Expand Down
2 changes: 1 addition & 1 deletion ci/jpa-3.2-tck.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ else {
pipeline {
agent none
tools {
jdk 'OpenJDK 17 Latest'
jdk 'OpenJDK 21 Latest'
}
options {
rateLimitBuilds(throttle: [count: throttleCount, durationName: 'day', userBoost: true])
Expand Down
2 changes: 1 addition & 1 deletion ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pipeline {
cron('0 0 * * 0')
}
tools {
jdk 'OpenJDK 17 Latest'
jdk 'OpenJDK 21 Latest'
}
options {
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
Expand Down
2 changes: 1 addition & 1 deletion ci/snapshot-publish.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pipeline {
label 'Release'
}
tools {
jdk 'OpenJDK 17 Latest'
jdk 'OpenJDK 21 Latest'
}
options {
rateLimitBuilds(throttle: [count: 1, durationName: 'hour', userBoost: true])
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ org.gradle.java.installations.auto-download=false

# externalized definition of JDK versions so that they are available in both Project (build.gradle) and Settings (settings.gradle)
orm.jdk.base=17
orm.jdk.max=22
orm.jdk.min=21
orm.jdk.max=24
10 changes: 0 additions & 10 deletions hibernate-jfr/hibernate-jfr.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,3 @@ dependencies {
testImplementation project( ':hibernate-testing' )
testImplementation testLibs.jfrUnit
}


// JfrUnit requires JDK 17
compileTestJava.onlyIf{
jdkVersions.test.release.asInt() >= 17
}

test.onlyIf {
jdkVersions.test.release.asInt() >= 17
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
import org.gradle.jvm.toolchain.JavaToolchainService;

/**
* Retrieves JDK versions exposed by {@link JdkVersionPlugin}
* and injects them in build tasks.
*
* @see JdkVersionConfig
* @see JdkVersionSettingsPlugin
* @see JdkVersionPlugin
*
* @author Steve Ebersole
*/
public class JavaModulePlugin implements Plugin<Project> {
Expand Down Expand Up @@ -57,11 +64,11 @@ public void apply(Project project) {
mainCompileTask.setSourceCompatibility( jdkVersionsConfig.getMainReleaseVersion().toString() );
mainCompileTask.setTargetCompatibility( jdkVersionsConfig.getMainReleaseVersion().toString() );

testCompileTask.setSourceCompatibility( jdkVersionsConfig.getTestCompileVersion().toString() );
testCompileTask.setTargetCompatibility( jdkVersionsConfig.getTestCompileVersion().toString() );
testCompileTask.setSourceCompatibility( jdkVersionsConfig.getTestCompilerVersion().toString() );
testCompileTask.setTargetCompatibility( jdkVersionsConfig.getTestCompilerVersion().toString() );
}
else {
javaPluginExtension.getToolchain().getLanguageVersion().set( jdkVersionsConfig.getMainCompileVersion() );
javaPluginExtension.getToolchain().getLanguageVersion().set( jdkVersionsConfig.getMainCompilerVersion() );

configureCompileTasks( project );
configureTestTasks( project );
Expand All @@ -72,7 +79,7 @@ public void apply(Project project) {

testCompileTask.getJavaCompiler().set(
toolchainService.compilerFor( javaToolchainSpec -> {
javaToolchainSpec.getLanguageVersion().set( jdkVersionsConfig.getTestCompileVersion() );
javaToolchainSpec.getLanguageVersion().set( jdkVersionsConfig.getTestCompilerVersion() );
} )
);
if ( testTask != null ) {
Expand Down
Loading