HHH-14946 Upgrading base requirements to Java 11
This commit is contained in:
parent
dc744844e4
commit
334aeb1349
|
@ -18,7 +18,7 @@ for its CI needs. See
|
||||||
|
|
||||||
== Building from sources
|
== Building from sources
|
||||||
|
|
||||||
The build requires at least Java 8 JDK.
|
The build requires at least Java 11 JDK.
|
||||||
|
|
||||||
Hibernate uses https://gradle.org[Gradle] as its build tool. See the _Gradle Primer_ section below if you are new to
|
Hibernate uses https://gradle.org[Gradle] as its build tool. See the _Gradle Primer_ section below if you are new to
|
||||||
Gradle.
|
Gradle.
|
||||||
|
|
|
@ -69,10 +69,8 @@ task release {
|
||||||
def javaVersionsInUse = [gradle.ext.javaVersions.main.compiler, gradle.ext.javaVersions.main.release,
|
def javaVersionsInUse = [gradle.ext.javaVersions.main.compiler, gradle.ext.javaVersions.main.release,
|
||||||
gradle.ext.javaVersions.test.compiler, gradle.ext.javaVersions.test.release,
|
gradle.ext.javaVersions.test.compiler, gradle.ext.javaVersions.test.release,
|
||||||
gradle.ext.javaVersions.test.launcher].toSet()
|
gradle.ext.javaVersions.test.launcher].toSet()
|
||||||
// Force to release with JDK 8. It used to not work on JDK11 because of the hibernate-orm-modules module,
|
if ( javaVersionsInUse != [JavaLanguageVersion.of( 11 )].toSet() ) {
|
||||||
// but this limitation might be resolved now that this module has been deleted?
|
throw new IllegalStateException( "Please use JDK 11 to perform the release. Currently using: ${javaVersionsInUse}" )
|
||||||
if ( javaVersionsInUse != [JavaLanguageVersion.of( 8 )].toSet() ) {
|
|
||||||
throw new IllegalStateException( "Please use JDK 8 to perform the release. Currently using: ${javaVersionsInUse}" )
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,9 +376,6 @@ Just check the "Enable annotation processing" option, configure the directory fo
|
||||||
generated sources and finally add the Hibernate Static Metamodel Generator and Jakarta Persistence jar
|
generated sources and finally add the Hibernate Static Metamodel Generator and Jakarta Persistence jar
|
||||||
files to the factory path.
|
files to the factory path.
|
||||||
|
|
||||||
If you use JDK 11+, you also need to add the `javax.xml.bind:jaxb-api` and
|
|
||||||
`org.glassfish.jaxb:jaxb-runtime` jars as JAXB is not included in the JDK anymore.
|
|
||||||
|
|
||||||
image:eclipse-annotation-processor-config.png[]
|
image:eclipse-annotation-processor-config.png[]
|
||||||
|
|
||||||
=== Processor specific options
|
=== Processor specific options
|
||||||
|
|
|
@ -24,14 +24,7 @@ However, Hibernate can certainly help you to remove or encapsulate vendor-specif
|
||||||
|
|
||||||
== System Requirements
|
== System Requirements
|
||||||
|
|
||||||
Hibernate 5.2 and later versions require at least Java 1.8 and JDBC 4.2.
|
Hibernate 6.0 and later versions require at least Java 11 and JDBC 4.2.
|
||||||
|
|
||||||
Hibernate 5.1 and older versions require at least Java 1.6 and JDBC 4.0.
|
|
||||||
|
|
||||||
[TIP]
|
|
||||||
====
|
|
||||||
When building Hibernate 5.1 or older from sources, you need Java 1.7 due to a bug in the JDK 1.6 compiler.
|
|
||||||
====
|
|
||||||
|
|
||||||
=== Getting Started Guide
|
=== Getting Started Guide
|
||||||
|
|
||||||
|
|
|
@ -149,28 +149,14 @@ else {
|
||||||
// Configure generated bytecode
|
// Configure generated bytecode
|
||||||
// "sourceCompatibility" is not supported with toolchains. We have to work around that limitation.
|
// "sourceCompatibility" is not supported with toolchains. We have to work around that limitation.
|
||||||
tasks.compileJava.configure {
|
tasks.compileJava.configure {
|
||||||
if ( gradle.ext.javaVersions.main.compiler.asInt() < 9 ) {
|
options.release = gradle.ext.javaVersions.main.release.asInt()
|
||||||
options.compilerArgs << '-source'
|
// Needs add-opens because of https://github.com/gradle/gradle/issues/15538
|
||||||
options.compilerArgs << gradle.ext.javaVersions.main.release.toString()
|
options.forkOptions.jvmArgs.addAll( ["--add-opens", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"] )
|
||||||
options.compilerArgs << '-target'
|
|
||||||
options.compilerArgs << gradle.ext.javaVersions.main.release.toString()
|
|
||||||
} else {
|
|
||||||
options.release = gradle.ext.javaVersions.main.release.asInt()
|
|
||||||
// Needs add-opens because of https://github.com/gradle/gradle/issues/15538
|
|
||||||
options.forkOptions.jvmArgs.addAll( ["--add-opens", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"] )
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tasks.compileTestJava.configure {
|
tasks.compileTestJava.configure {
|
||||||
if ( gradle.ext.javaVersions.test.compiler.asInt() < 9 ) {
|
options.release = gradle.ext.javaVersions.test.release.asInt()
|
||||||
options.compilerArgs << '-source'
|
// Needs add-opens because of https://github.com/gradle/gradle/issues/15538
|
||||||
options.compilerArgs << gradle.ext.javaVersions.test.release.toString()
|
options.forkOptions.jvmArgs.addAll( ["--add-opens", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"] )
|
||||||
options.compilerArgs << '-target'
|
|
||||||
options.compilerArgs << gradle.ext.javaVersions.test.release.toString()
|
|
||||||
} else {
|
|
||||||
options.release = gradle.ext.javaVersions.test.release.asInt()
|
|
||||||
// Needs add-opens because of https://github.com/gradle/gradle/issues/15538
|
|
||||||
options.forkOptions.jvmArgs.addAll( ["--add-opens", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"] )
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure version of Java tools
|
// Configure version of Java tools
|
||||||
|
@ -268,10 +254,8 @@ tasks.withType( Test.class ).each { test ->
|
||||||
|
|
||||||
test.usesService( project.gradle.sharedServices.registrations.getByName( 'databaseService' ).service )
|
test.usesService( project.gradle.sharedServices.registrations.getByName( 'databaseService' ).service )
|
||||||
|
|
||||||
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
|
// Byteman needs this property to be set, https://developer.jboss.org/thread/274997
|
||||||
// Byteman needs this property to be set, https://developer.jboss.org/thread/274997
|
test.jvmArgs += ["-Djdk.attach.allowAttachSelf=true"]
|
||||||
test.jvmArgs += ["-Djdk.attach.allowAttachSelf=true"]
|
|
||||||
}
|
|
||||||
|
|
||||||
test.jvmArgumentProviders.add(
|
test.jvmArgumentProviders.add(
|
||||||
new HeapDumpPathProvider( path: project.layout.buildDirectory.dir("OOM-dump") )
|
new HeapDumpPathProvider( path: project.layout.buildDirectory.dir("OOM-dump") )
|
||||||
|
|
|
@ -45,7 +45,7 @@ javadoc {
|
||||||
use = true
|
use = true
|
||||||
encoding = 'UTF-8'
|
encoding = 'UTF-8'
|
||||||
links += [
|
links += [
|
||||||
'https://docs.oracle.com/javase/8/docs/api/',
|
'https://docs.oracle.com/en/java/javase/11/docs/api/',
|
||||||
'https://jakarta.ee/specifications/platform/9/apidocs/'
|
'https://jakarta.ee/specifications/platform/9/apidocs/'
|
||||||
]
|
]
|
||||||
tags = [ "apiNote", 'implSpec', 'implNote', 'todo' ]
|
tags = [ "apiNote", 'implSpec', 'implNote', 'todo' ]
|
||||||
|
|
|
@ -193,13 +193,11 @@ task generateEnversStaticMetamodel(
|
||||||
tasks.withType( Test.class ).each { test ->
|
tasks.withType( Test.class ).each { test ->
|
||||||
test.systemProperty 'file.encoding', 'utf-8'
|
test.systemProperty 'file.encoding', 'utf-8'
|
||||||
|
|
||||||
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
|
// See org.hibernate.boot.model.naming.NamingHelperTest.DefaultCharset.set
|
||||||
// See org.hibernate.boot.model.naming.NamingHelperTest.DefaultCharset.set
|
test.jvmArgs( ['--add-opens', 'java.base/java.nio.charset=ALL-UNNAMED'] )
|
||||||
test.jvmArgs( ['--add-opens', 'java.base/java.nio.charset=ALL-UNNAMED'] )
|
// Weld needs this to generate proxies
|
||||||
// Weld needs this to generate proxies
|
test.jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
|
||||||
test.jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
|
test.jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
||||||
test.jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
|
||||||
}
|
|
||||||
|
|
||||||
test.beforeTest { descriptor ->
|
test.beforeTest { descriptor ->
|
||||||
//println "Starting test: " + descriptor
|
//println "Starting test: " + descriptor
|
||||||
|
|
|
@ -20,8 +20,8 @@ dependencies {
|
||||||
|
|
||||||
tasks.compileJava {
|
tasks.compileJava {
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
sourceCompatibility = 8
|
sourceCompatibility = 11
|
||||||
targetCompatibility = 8
|
targetCompatibility = 11
|
||||||
}
|
}
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
|
|
|
@ -18,13 +18,11 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
|
// Proxool needs this to define classes for some reason. Stack trace:
|
||||||
// Proxool needs this to define classes for some reason. Stack trace:
|
// at org.logicalcobwebs.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:372)
|
||||||
// at org.logicalcobwebs.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:372)
|
// at org.logicalcobwebs.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:193)
|
||||||
// at org.logicalcobwebs.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:193)
|
// at org.logicalcobwebs.cglib.core.KeyFactory$Generator.create(KeyFactory.java:177)
|
||||||
// at org.logicalcobwebs.cglib.core.KeyFactory$Generator.create(KeyFactory.java:177)
|
// at org.logicalcobwebs.cglib.core.KeyFactory.create(KeyFactory.java:149)
|
||||||
// at org.logicalcobwebs.cglib.core.KeyFactory.create(KeyFactory.java:149)
|
// at org.logicalcobwebs.cglib.proxy.Enhancer.<clinit>(Enhancer.java:96)
|
||||||
// at org.logicalcobwebs.cglib.proxy.Enhancer.<clinit>(Enhancer.java:96)
|
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
||||||
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -189,15 +189,13 @@ task aggregateJavadocs(type: Javadoc) {
|
||||||
'https://javaee.github.io/javaee-spec/javadocs/'
|
'https://javaee.github.io/javaee-spec/javadocs/'
|
||||||
]
|
]
|
||||||
|
|
||||||
if ( gradle.ext.javaVersions.main.compiler.asInt() >= 11 ) {
|
//The need to set `--source 1.8` applies to all JVMs after 11, and also to 11
|
||||||
//The need to set `--source 1.8` applies to all JVMs after 11, and also to 11
|
// but after excluding the first two builds; see also specific comments on
|
||||||
// but after excluding the first two builds; see also specific comments on
|
// https://bugs.openjdk.java.net/browse/JDK-8212233?focusedCommentId=14245762
|
||||||
// https://bugs.openjdk.java.net/browse/JDK-8212233?focusedCommentId=14245762
|
// For now, let's be compatible with JDK 11.0.3+. We can improve on it if people
|
||||||
// For now, let's be compatible with JDK 11.0.3+. We can improve on it if people
|
// complain they cannot build with JDK 11.0.0, 11.0.1 and 11.0.2.
|
||||||
// complain they cannot build with JDK 11.0.0, 11.0.1 and 11.0.2.
|
logger.lifecycle "Forcing Javadoc in Java 8 compatible mode"
|
||||||
logger.lifecycle "Forcing Javadoc in Java 8 compatible mode"
|
options.source = gradle.ext.baselineJavaVersion
|
||||||
options.source = gradle.ext.baselineJavaVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
options.addStringOption( 'Xdoclint:none', '-quiet' )
|
options.addStringOption( 'Xdoclint:none', '-quiet' )
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ includeBuild('hibernate-orm-build')
|
||||||
|
|
||||||
apply from: file( 'gradle/gradle-enterprise.gradle' )
|
apply from: file( 'gradle/gradle-enterprise.gradle' )
|
||||||
|
|
||||||
if ( !JavaVersion.current().java8Compatible ) {
|
if ( !JavaVersion.current().java11Compatible ) {
|
||||||
throw new GradleException( "Gradle must be run with Java 8 or later" )
|
throw new GradleException( "Gradle must be run with Java 11 or later" )
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCache {
|
buildCache {
|
||||||
|
@ -38,7 +38,7 @@ buildCache {
|
||||||
remote(HttpBuildCache) { enabled = false }
|
remote(HttpBuildCache) { enabled = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
gradle.ext.baselineJavaVersion = JavaLanguageVersion.of( 8 )
|
gradle.ext.baselineJavaVersion = JavaLanguageVersion.of( 11 )
|
||||||
|
|
||||||
// Gradle does bytecode transformation on tests.
|
// Gradle does bytecode transformation on tests.
|
||||||
// You can't use bytecode higher than what Gradle supports, even with toolchains.
|
// You can't use bytecode higher than what Gradle supports, even with toolchains.
|
||||||
|
@ -129,18 +129,7 @@ include 'hibernate-jcache'
|
||||||
|
|
||||||
include 'hibernate-micrometer'
|
include 'hibernate-micrometer'
|
||||||
include 'hibernate-graalvm'
|
include 'hibernate-graalvm'
|
||||||
|
include 'hibernate-integrationtest-java-modules'
|
||||||
// The plugin used to generate Java modules was compiled using JDK11.
|
|
||||||
// This means even with toolchains, Gradle needs to be run with Java 11+ in order to run Java modules ITs.
|
|
||||||
// We might be able to get rid of that limitation by relying on Gradle's built-in support for Java modules,
|
|
||||||
// but I (Yoann) tried and failed to make it work.
|
|
||||||
// See https://docs.gradle.org/current/samples/sample_java_modules_multi_project.html
|
|
||||||
if ( JavaVersion.current().isJava11Compatible() && gradle.ext.javaVersions.test.release.asInt() >= 9 ) {
|
|
||||||
include 'hibernate-integrationtest-java-modules'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.warn( '[WARN] Skipping Java module path integration tests because the JDK does not support it' )
|
|
||||||
}
|
|
||||||
|
|
||||||
include 'documentation'
|
include 'documentation'
|
||||||
include 'release'
|
include 'release'
|
||||||
|
|
|
@ -87,10 +87,8 @@ else {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
|
// Needs add-opens because Gradle uses illegal accesses to inject... mocks? Something like that.
|
||||||
// Needs add-opens because Gradle uses illegal accesses to inject... mocks? Something like that.
|
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
||||||
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task release {
|
task release {
|
||||||
|
|
|
@ -76,5 +76,5 @@ task( "compile" ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
configure<JavaPluginConvention> {
|
configure<JavaPluginConvention> {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue