HHH-13682 Generate Java 13/14 bytecode for tests when building with JDK13/14
This commit is contained in:
parent
c906989989
commit
0cdf4c19e3
|
@ -13,6 +13,21 @@ ext {
|
||||||
jpaVersion = new JpaVersion('2.2')
|
jpaVersion = new JpaVersion('2.2')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( JavaVersion.current() == JavaVersion.VERSION_HIGHER ) {
|
||||||
|
// This JDK is not supported by Gradle.
|
||||||
|
// Use a hack to retrieve the major as a string.
|
||||||
|
|
||||||
|
// This only works for Java 9+ (we're at least on Java 13 here).
|
||||||
|
def major = System.getProperty( 'java.specification.version' )
|
||||||
|
logger.warn( "[WARN] The Java version '$major' is not supported by gradle." )
|
||||||
|
|
||||||
|
ext.testedJavaVersion = major
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// This JDK is supported by Gradle.
|
||||||
|
ext.testedJavaVersion = JavaVersion.current()
|
||||||
|
}
|
||||||
|
|
||||||
group = 'org.hibernate'
|
group = 'org.hibernate'
|
||||||
version = project.ormVersion.fullName
|
version = project.ormVersion.fullName
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,6 @@ ext {
|
||||||
forbiddenAPITargetJDKCompatibility = '11'
|
forbiddenAPITargetJDKCompatibility = '11'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sourceCompatibility = project.baselineJavaVersion
|
|
||||||
targetCompatibility = project.baselineJavaVersion
|
|
||||||
|
|
||||||
if ( !project.description ) {
|
if ( !project.description ) {
|
||||||
project.description = "The Hibernate ORM $project.name module"
|
project.description = "The Hibernate ORM $project.name module"
|
||||||
}
|
}
|
||||||
|
@ -115,8 +111,20 @@ dependencies {
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Compilation
|
// Compilation
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType( JavaCompile ) {
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
|
sourceCompatibility = project.baselineJavaVersion
|
||||||
|
targetCompatibility = project.baselineJavaVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( project.baselineJavaVersion != project.testedJavaVersion ) {
|
||||||
|
logger.info( "Forcing the target bytecode version for test classes to '$project.testedJavaVersion'" )
|
||||||
|
|
||||||
|
tasks.compileTestJava {
|
||||||
|
// For *tests only*, generate bytecode matching the Java version currently in use.
|
||||||
|
// This allows testing bytecode enhancement on the latest Java versions (13, 14, ...).
|
||||||
|
targetCompatibility = project.testedJavaVersion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] )
|
task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] )
|
||||||
|
|
|
@ -24,10 +24,12 @@ apply from: rootProject.file( 'gradle/java-module.gradle' )
|
||||||
// so we have to use https://github.com/java9-modularity/gradle-modules-plugin
|
// so we have to use https://github.com/java9-modularity/gradle-modules-plugin
|
||||||
apply plugin: "org.javamodularity.moduleplugin"
|
apply plugin: "org.javamodularity.moduleplugin"
|
||||||
|
|
||||||
// Override -source and -target
|
// Override -source and -target to the version being tested (11+, since this module is enabled)
|
||||||
ext.baselineJavaVersion = 11
|
ext.baselineJavaVersion = project.testedJavaVersion
|
||||||
sourceCompatibility = project.baselineJavaVersion
|
tasks.withType( JavaCompile ) {
|
||||||
targetCompatibility = project.baselineJavaVersion
|
sourceCompatibility = project.baselineJavaVersion
|
||||||
|
targetCompatibility = project.baselineJavaVersion
|
||||||
|
}
|
||||||
|
|
||||||
// Checkstyle fails for module-info
|
// Checkstyle fails for module-info
|
||||||
checkstyleMain.exclude '**/module-info.java'
|
checkstyleMain.exclude '**/module-info.java'
|
||||||
|
|
Loading…
Reference in New Issue