From 26e2afc9890e6f0af662da9b1cd7b99cbee7f5eb Mon Sep 17 00:00:00 2001 From: Aaron Chung Date: Tue, 13 Feb 2024 09:57:31 -0800 Subject: [PATCH] add latest updates from 6.2.22 to hibernate test files --- wrapper/build.gradle.kts | 1 + wrapper/src/test/build.gradle.kts | 1 + .../integration/host/TestEnvironment.java | 2 +- .../hibernate_files/databases.gradle | 81 ++++++++- .../hibernate_files/hibernate-core.gradle | 39 ++-- .../hibernate_files/java-module.gradle | 169 ++++++++---------- 6 files changed, 176 insertions(+), 117 deletions(-) diff --git a/wrapper/build.gradle.kts b/wrapper/build.gradle.kts index fbc764c95..fb29da7e0 100644 --- a/wrapper/build.gradle.kts +++ b/wrapper/build.gradle.kts @@ -24,6 +24,7 @@ plugins { id("com.github.vlsi.gradle-extensions") id("com.github.vlsi.ide") id("com.kncept.junit.reporter") + id("org.checkerframework") version "0.6.34" } dependencies { diff --git a/wrapper/src/test/build.gradle.kts b/wrapper/src/test/build.gradle.kts index 29b27b157..53da4faf5 100644 --- a/wrapper/src/test/build.gradle.kts +++ b/wrapper/src/test/build.gradle.kts @@ -19,6 +19,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent.* plugins { java + id("org.checkerframework") version "0.6.34" } repositories { diff --git a/wrapper/src/test/java/integration/host/TestEnvironment.java b/wrapper/src/test/java/integration/host/TestEnvironment.java index 5788bfab9..eb12abe55 100644 --- a/wrapper/src/test/java/integration/host/TestEnvironment.java +++ b/wrapper/src/test/java/integration/host/TestEnvironment.java @@ -68,7 +68,7 @@ public class TestEnvironment implements AutoCloseable { private static final String PROXIED_DOMAIN_NAME_SUFFIX = ".proxied"; protected static final int PROXY_CONTROL_PORT = 8474; protected static final int PROXY_PORT = 8666; - private static final String HIBERNATE_VERSION = "6.2.0.CR2"; + private static final String HIBERNATE_VERSION = "6.2.22"; private static final TestEnvironmentConfiguration config = new TestEnvironmentConfiguration(); private static final boolean USE_OTLP_CONTAINER_FOR_TRACES = true; diff --git a/wrapper/src/test/resources/hibernate_files/databases.gradle b/wrapper/src/test/resources/hibernate_files/databases.gradle index 0b0a1761f..be462ee4f 100644 --- a/wrapper/src/test/resources/hibernate_files/databases.gradle +++ b/wrapper/src/test/resources/hibernate_files/databases.gradle @@ -12,6 +12,7 @@ ext { db = project.hasProperty('db') ? project.getProperty('db') : 'h2' dbHost = System.getProperty( 'dbHost', 'localhost' ) dbService = System.getProperty( 'dbService', '' ) + runID = System.getProperty( 'runID', '' ) dbUser = System.getProperty( 'dbUser', 'hibernate_orm_test' ) dbPass = System.getProperty( 'dbPass', 'hibernate_orm_test' ) dbName = System.getProperty( 'dbName', 'hibernate_orm_test' ) @@ -37,8 +38,9 @@ ext { 'jdbc.driver': 'org.h2.Driver', 'jdbc.user' : 'sa', 'jdbc.pass' : '', - 'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000', - 'connection.init_sql' : '' + 'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE', + 'connection.init_sql' : '', + 'hibernate.dialect.native_param_markers' : 'true' ], hsqldb : [ 'db.dialect' : 'org.hibernate.dialect.HSQLDialect', @@ -53,7 +55,7 @@ ext { 'jdbc.driver': 'org.apache.derby.iapi.jdbc.AutoloadedDriver', 'jdbc.user' : 'hibernate_orm_test', 'jdbc.pass' : 'hibernate_orm_test', - 'jdbc.url' : 'jdbc:derby:target/tmp/derby/hibernate_orm_test;databaseName=hibernate_orm_test;create=true', + 'jdbc.url' : 'jdbc:derby:memory:;databaseName=hibernate_orm_test;create=true', 'connection.init_sql' : '' ], derby_old : [ @@ -61,7 +63,7 @@ ext { 'jdbc.driver': 'org.apache.derby.jdbc.EmbeddedDriver', 'jdbc.user' : 'hibernate_orm_test', 'jdbc.pass' : 'hibernate_orm_test', - 'jdbc.url' : 'jdbc:derby:target/tmp/derby/hibernate_orm_test;databaseName=hibernate_orm_test;create=true', + 'jdbc.url' : 'jdbc:derby:memory:;databaseName=hibernate_orm_test;create=true', 'connection.init_sql' : '' ], pgsql : [ @@ -97,9 +99,18 @@ ext { 'jdbc.user' : 'hibernate_orm_test', 'jdbc.pass' : 'hibernate_orm_test', // Disable prepared statement caching to avoid issues with changing schemas - 'jdbc.url' : 'jdbc:jtds:sybase://' + dbHost + ':5000/hibernate_orm_test;maxStatements=0;cacheMetaData=false', + 'jdbc.url' : 'jdbc:jtds:sybase://' + dbHost + ':9000/hibernate_orm_test;maxStatements=0;cacheMetaData=false', 'connection.init_sql' : 'set ansinull on' ], + sybase_jconn_ci : [ + 'db.dialect' : 'org.hibernate.dialect.SybaseASEDialect', + 'jdbc.driver': 'com.sybase.jdbc4.jdbc.SybDriver', + 'jdbc.user' : 'hibernate_orm_test', + 'jdbc.pass' : 'hibernate_orm_test', + // Disable prepared statement caching to avoid issues with changing schemas + 'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':9000/hibernate_orm_test', + 'connection.init_sql' : 'set ansinull on set quoted_identifier on' + ], mysql : [ 'db.dialect' : 'org.hibernate.dialect.MySQLDialect', 'jdbc.driver': 'com.mysql.cj.jdbc.Driver', @@ -137,7 +148,7 @@ ext { 'jdbc.driver': 'com.mysql.jdbc.Driver', 'jdbc.user' : 'hibernate_orm_test', 'jdbc.pass' : 'hibernate_orm_test', - 'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test', + 'jdbc.url' : 'jdbc:mysql://' + dbHost + ':4000/hibernate_orm_test', 'connection.init_sql' : '' ], oracle : [ @@ -149,6 +160,14 @@ ext { 'connection.init_sql' : '' ], oracle_ci : [ + 'db.dialect' : 'org.hibernate.dialect.OracleDialect', + 'jdbc.driver': 'oracle.jdbc.OracleDriver', + 'jdbc.user' : 'hibernate_orm_test', + 'jdbc.pass' : 'hibernate_orm_test', + 'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/freepdb1', + 'connection.init_sql' : '' + ], + oracle_xe_ci : [ 'db.dialect' : 'org.hibernate.dialect.OracleDialect', 'jdbc.driver': 'oracle.jdbc.OracleDriver', 'jdbc.user' : 'hibernate_orm_test', @@ -168,13 +187,49 @@ ext { oracle_cloud_autonomous_tls : [ 'db.dialect' : 'org.hibernate.dialect.OracleDialect', 'jdbc.driver': 'oracle.jdbc.OracleDriver', - 'jdbc.user' : 'hibernate_orm_test', + 'jdbc.user' : 'hibernate_orm_test_' + runID, + 'jdbc.pass' : 'Oracle_19_Password', + // Requires dbHost (pointing to the right cloud region) AND dbService (unique database name). + // + // To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation: + // https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html + 'jdbc.url' : 'jdbc:oracle:thin:@(description=(retry_count=5)(retry_delay=1)(address=(protocol=tcps)(port=1521)(host=' + dbHost + '.oraclecloud.com))(connect_data=(service_name=' + dbService + '_tp.adb.oraclecloud.com))(security=(ssl_server_dn_match=no)))?oracle.jdbc.enableQueryResultCache=false&oracle.jdbc.thinForceDNSLoadBalancing=true&tcp.nodelay=yes', + 'connection.init_sql' : '' + ], + oracle_cloud_db19c : [ + 'db.dialect' : 'org.hibernate.dialect.OracleDialect', + 'jdbc.driver': 'oracle.jdbc.OracleDriver', + 'jdbc.user' : 'hibernate_orm_test_' + runID, 'jdbc.pass' : 'Oracle_19_Password', // Requires dbHost (pointing to the right cloud region) AND dbService (unique database name). // // To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation: // https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html - 'jdbc.url' : 'jdbc:oracle:thin:@(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=' + dbHost + '.oraclecloud.com))(connect_data=(service_name=' + dbService + '_low.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))', + 'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/' + dbService, + 'connection.init_sql' : '' + ], + oracle_cloud_db21c : [ + 'db.dialect' : 'org.hibernate.dialect.OracleDialect', + 'jdbc.driver': 'oracle.jdbc.OracleDriver', + 'jdbc.user' : 'hibernate_orm_test_' + runID, + 'jdbc.pass' : 'Oracle_21_Password', + // Requires dbHost (pointing to the right cloud region) AND dbService (unique database name). + // + // To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation: + // https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html + 'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/' + dbService, + 'connection.init_sql' : '' + ], + oracle_cloud_db23c : [ + 'db.dialect' : 'org.hibernate.dialect.OracleDialect', + 'jdbc.driver': 'oracle.jdbc.OracleDriver', + 'jdbc.user' : 'hibernate_orm_test_' + runID, + 'jdbc.pass' : 'Oracle_23_Password', + // Requires dbHost (pointing to the right cloud region) AND dbService (unique database name). + // + // To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation: + // https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html + 'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/' + dbService, 'connection.init_sql' : '' ], mssql : [ @@ -256,6 +311,14 @@ ext { 'jdbc.url' : 'jdbc:firebirdsql://' + dbHost +'/hibernate_orm_test?charSet=utf-8;TRANSACTION_READ_COMMITTED=read_committed,rec_version,wait,lock_timeout=5', 'connection.init_sql' : '' ], + altibase : [ + 'db.dialect' : 'org.hibernate.community.dialect.AltibaseDialect', + 'jdbc.driver': 'Altibase.jdbc.driver.AltibaseDriver', + 'jdbc.user' : 'sys', + 'jdbc.pass' : 'manager', + 'connection.init_sql' : '', + 'jdbc.url' : 'jdbc:Altibase://' + dbHost + ':20300/mydb?force_clob_bind=true' + ], ] } @@ -266,7 +329,7 @@ if ( processTestResourcesTask != null ) { processTestResourcesTask.inputs.property( 'dbHost', dbHost ) // processTestResourcesTask.inputs.property( "gradle.libs.versions.h2", project.getProperty( "gradle.libs.versions.h2", "2.1.214" ) ) // processTestResourcesTask.inputs.property( "gradle.libs.versions.h2gis", project.getProperty( "gradle.libs.versions.h2gis", "2.1.0" ) ) -// processTestResourcesTask.inputs.property( "gradle.libs.versions.hsqldb", project.getProperty( "gradle.libs.versions.hsqldb", "2.7.1" ) ) +// processTestResourcesTask.inputs.property( "gradle.libs.versions.hsqldb", project.getProperty( "gradle.libs.versions.hsqldb", "2.7.2" ) ) // processTestResourcesTask.inputs.property( "gradle.libs.versions.derby", project.getProperty( "gradle.libs.versions.derby", "10.15.2.0" ) ) processTestResourcesTask.filter( ReplaceTokens, tokens: dbBundle[db] ) } diff --git a/wrapper/src/test/resources/hibernate_files/hibernate-core.gradle b/wrapper/src/test/resources/hibernate_files/hibernate-core.gradle index 72d8f6777..97cdc00cb 100644 --- a/wrapper/src/test/resources/hibernate_files/hibernate-core.gradle +++ b/wrapper/src/test/resources/hibernate_files/hibernate-core.gradle @@ -10,13 +10,16 @@ plugins { id 'org.hibernate.build.xjc-jakarta' } +repositories { + gradlePluginPortal() +} + description = 'Hibernate\'s core ORM functionality' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) apply plugin: 'org.hibernate.orm.antlr' apply plugin: 'org.hibernate.matrix-test' - configurations { tests { description = 'Configuration for the produced test jar' @@ -45,6 +48,7 @@ dependencies { compileOnly jakartaLibs.jsonbApi compileOnly libs.jackson compileOnly libs.jacksonXml + compileOnly dbLibs.postgresql testImplementation project(':hibernate-testing') testImplementation project(':hibernate-ant') @@ -62,14 +66,15 @@ dependencies { } testImplementation "joda-time:joda-time:2.3" testImplementation files('/app/libs/aws-advanced-jdbc-wrapper-2.3.3.jar') - testImplementation dbLibs.postgresql - testImplementation dbLibs.mysql testImplementation dbLibs.h2 testRuntimeOnly libs.byteBuddy testRuntimeOnly testLibs.weld testRuntimeOnly testLibs.wildFlyTxnClient + testRuntimeOnly jakartaLibs.jsonb testRuntimeOnly libs.jackson + testRuntimeOnly libs.jacksonXml + testRuntimeOnly libs.jacksonJsr310 testAnnotationProcessor project( ':hibernate-jpamodelgen' ) @@ -105,10 +110,8 @@ sourceSets { } } - // resources inherently exclude sources test { resources { - srcDir 'src/test/java' srcDir 'src/test/resources' srcDir 'src/test/bundles' } @@ -240,13 +243,16 @@ tasks.withType( Test.class ).each { test -> test.jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] ) test.jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] ) + //Avoid Log4J2 classloader leaks: + test.jvmArgs( ['-Dlog4j2.disableJmx=true'] ) + test.beforeTest { descriptor -> //println "Starting test: " + descriptor } } // Tests with records -if ( gradle.ext.javaVersions.test.release.asInt() >= 17 && gradle.ext.javaToolchainEnabled ) { +if ( jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit ) { // Add a new source set, which contains tests that can run on JDK17+ sourceSets { @@ -256,7 +262,7 @@ if ( gradle.ext.javaVersions.test.release.asInt() >= 17 && gradle.ext.javaToolch } // Refer to the main test resources to avoid processing variables twice resources { - srcDir 'target/resources/test' + srcDirs tasks.processTestResources } } } @@ -264,7 +270,7 @@ if ( gradle.ext.javaVersions.test.release.asInt() >= 17 && gradle.ext.javaToolch // For the new source set, we need to configure the source and target version to 17 compileTestJava17Java { javaCompiler = javaToolchains.compilerFor { - languageVersion = gradle.ext.javaVersions.test.compiler + languageVersion = jdkVersions.test.compiler } sourceCompatibility = 17 targetCompatibility = 17 @@ -275,6 +281,7 @@ if ( gradle.ext.javaVersions.test.release.asInt() >= 17 && gradle.ext.javaToolch // The source set gets a custom configuration which extends the normal test implementation config configurations { testJava17Implementation.extendsFrom(testImplementation, testRuntimeOnly) + testJava17CompileOnly.extendsFrom(testCompileOnly) } // Add the output from src/main/java as dependency @@ -287,14 +294,14 @@ if ( gradle.ext.javaVersions.test.release.asInt() >= 17 && gradle.ext.javaToolch // We execute the Java 17 tests in a custom test task task testJava17(type: Test) { javaLauncher = javaToolchains.launcherFor { - languageVersion = gradle.ext.javaVersions.test.launcher + languageVersion = jdkVersions.test.launcher } useJUnitPlatform() testClassesDirs = sourceSets.testJava17.output.classesDirs classpath = sourceSets.testJava17.runtimeClasspath - if ( gradle.ext.javaVersions.test.launcher.asInt() >= 19 ) { - logger.warn( "The version of Java bytecode that will be tested is not supported by Bytebuddy by default. " + + if ( jdkVersions.test.launcher.asInt() >= 19 ) { + logger.warn( "The version of Java bytecode that will be tested is not supported by Byte Buddy by default. " + " Setting 'net.bytebuddy.experimental=true'." ) systemProperty 'net.bytebuddy.experimental', true } @@ -305,9 +312,13 @@ if ( gradle.ext.javaVersions.test.release.asInt() >= 17 && gradle.ext.javaToolch check.dependsOn testJava17 } -javadoc { +tasks.named( "javadoc", Javadoc ) { configure(options) { - overview = 'src/main/javadoc/overview.html' - stylesheetFile = new File(projectDir, 'src/main/javadoc/stylesheet.css') + overview = rootProject.file( "shared/javadoc/overview.html" ) } } + +tasks.sourcesJar.dependsOn ':hibernate-core:generateGraphParser' +tasks.sourcesJar.dependsOn ':hibernate-core:generateHqlParser' +tasks.sourcesJar.dependsOn ':hibernate-core:generateSqlScriptParser' +tasks.sourcesJar.dependsOn ':hibernate-core:generateOrderingParser' diff --git a/wrapper/src/test/resources/hibernate_files/java-module.gradle b/wrapper/src/test/resources/hibernate_files/java-module.gradle index 429de7fb5..5e5df5bea 100644 --- a/wrapper/src/test/resources/hibernate_files/java-module.gradle +++ b/wrapper/src/test/resources/hibernate_files/java-module.gradle @@ -14,22 +14,24 @@ buildscript { mavenCentral() } dependencies { - classpath 'de.thetaphi:forbiddenapis:3.2' + classpath 'de.thetaphi:forbiddenapis:3.5.1' } } import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis import org.apache.tools.ant.filters.ReplaceTokens +apply plugin: 'java-library' + apply from: rootProject.file( 'gradle/module.gradle' ) -apply from: rootProject.file( 'gradle/libraries.gradle' ) apply from: rootProject.file( 'gradle/databases.gradle' ) +apply from: rootProject.file( 'gradle/javadoc.gradle' ) -apply plugin: 'org.hibernate.orm.database-service' - -apply plugin: 'java-library' apply plugin: 'biz.aQute.bnd.builder' apply plugin: 'org.hibernate.orm.database-service' +apply plugin: 'org.hibernate.orm.build.java-module' + +apply plugin: 'org.checkerframework' apply plugin: 'checkstyle' apply plugin: 'build-dashboard' @@ -57,6 +59,15 @@ if ( !project.description ) { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Configurations and Dependencies +configurations.configureEach { + resolutionStrategy.eachDependency { details -> + //Force the "byte buddy agent" version to match the Byte Buddy version + // we use, as Mockito might pull in a mismatched version transitively + if (details.requested.group == "net.bytebuddy" && details.requested.name == 'byte-buddy-agent') { + details.useVersion libs.versions.byteBuddy.get() + } + } +} dependencies { implementation libs.logging @@ -89,10 +100,8 @@ dependencies { testRuntimeOnly dbLibs.mssql testRuntimeOnly dbLibs.informix testRuntimeOnly dbLibs.cockroachdb - testRuntimeOnly dbLibs.oracle - testRuntimeOnly dbLibs.oracleXml - testRuntimeOnly dbLibs.oracleXmlParser testRuntimeOnly dbLibs.sybase + testRuntimeOnly rootProject.fileTree(dir: 'drivers', include: '*.jar') // Since both the DB2 driver and HANA have a package "net.jpountz" we have to add dependencies conditionally // This is due to the "no split-packages" requirement of Java 9+ @@ -115,6 +124,14 @@ dependencies { else if ( db.startsWith( 'firebird' ) ) { testRuntimeOnly dbLibs.firebird } + else if ( db.startsWith( 'oracle' ) ) { + testRuntimeOnly dbLibs.oracle + testRuntimeOnly dbLibs.oracleXml + testRuntimeOnly dbLibs.oracleXmlParser + } + else if ( db.startsWith( 'altibase' ) ) { + testRuntimeOnly dbLibs.altibase + } annotationProcessor libs.loggingProcessor annotationProcessor libs.logging @@ -153,64 +170,15 @@ artifacts { tasks.withType( JavaCompile ) { options.encoding = 'UTF-8' options.warnings false + options.fork = true + options.forkOptions.memoryMaximumSize = '768m' + // javaCompileTask.options.compilerArgs += [ // "-nowarn", // "-encoding", "UTF-8" // ] } -if ( !gradle.ext.javaToolchainEnabled ) { - tasks.compileJava.configure { - sourceCompatibility = JavaVersion.toVersion( gradle.ext.javaVersions.main.release ) - targetCompatibility = JavaVersion.toVersion( gradle.ext.javaVersions.main.release ) - } - tasks.compileTestJava.configure { - sourceCompatibility = JavaVersion.toVersion( gradle.ext.javaVersions.test.release ) - targetCompatibility = JavaVersion.toVersion( gradle.ext.javaVersions.test.release ) - } -} -else { - // Configure generated bytecode - // "sourceCompatibility" is not supported with toolchains. We have to work around that limitation. - tasks.compileJava.configure { - 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 { - 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 - java { - toolchain { - languageVersion = gradle.ext.javaVersions.main.compiler - } - } - tasks.compileTestJava { - javaCompiler = javaToolchains.compilerFor { - languageVersion = gradle.ext.javaVersions.test.compiler - } - } - - // Configure JVM Options - // Display version of Java tools - tasks.withType( JavaCompile ).configureEach { - options.forkOptions.jvmArgs.addAll( getProperty( 'toolchain.compiler.jvmargs' ).toString().split( ' ' ) ) - doFirst { - logger.lifecycle "Compiling with '${javaCompiler.get().metadata.installationPath}'" - } - } - tasks.withType( Javadoc ).configureEach { - options.setJFlags( getProperty( 'toolchain.javadoc.jvmargs' ).toString().split( ' ' ).toList().findAll( { !it.isEmpty() } ) ) - doFirst { - logger.lifecycle "Generating javadoc with '${javadocTool.get().metadata.installationPath}'" - } - } -} - task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] ) @@ -230,26 +198,6 @@ if ( toolsJar.exists() ) { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Testing - -if ( gradle.ext.javaToolchainEnabled ) { - tasks.test { - // Configure version of Java tools - javaLauncher = javaToolchains.launcherFor { - languageVersion = gradle.ext.javaVersions.test.launcher - } - - // Configure JVM Options - jvmArgs( getProperty( 'toolchain.launcher.jvmargs' ).toString().split( ' ' ) ) - if ( project.hasProperty( 'test.jdk.launcher.args' ) ) { - jvmArgs( project.getProperty( 'test.jdk.launcher.args' ).toString().split( ' ' ) ) - } - - // Display version of Java tools - doFirst { - logger.lifecycle "Testing with '${javaLauncher.get().metadata.installationPath}'" - } - } -} class HeapDumpPathProvider implements CommandLineArgumentProvider { @OutputDirectory Provider path @@ -280,6 +228,7 @@ tasks.withType( Test.class ).each { test -> test.maxHeapSize = '3G' test.systemProperties['hibernate.test.validatefailureexpected'] = true + test.systemProperties['hibernate.highlight_sql'] = false test.systemProperties += System.properties.findAll { it.key.startsWith( "hibernate." ) } test.enableAssertions = true @@ -299,13 +248,6 @@ tasks.withType( Test.class ).each { test -> sourceSets { test { resources { - // add `src/test/java` as a test-resources dir - configure( srcDir('src/test/java') ) { - filter { - include '**/*.properties' - include '**/*.xml' - } - } configure( srcDir('src/test/resources') ) { filter { include '*.properties' @@ -323,6 +265,7 @@ processTestResources { duplicatesStrategy DuplicatesStrategy.INCLUDE inputs.property( "db", db ) inputs.property( "dbHost", dbHost ) + inputs.file( rootProject.file( "gradle/databases.gradle" ) ) doLast { copy { from( sourceSets.test.java.srcDirs ) { @@ -354,15 +297,15 @@ test { jvmArgs '-XX:+StartAttachListener' } -// Enable the experimental features of ByteBuddy with JDK 19+ +// Enable the experimental features of ByteBuddy with JDK 22+ test { // We need to test the *launcher* version, // because some tests will use Mockito (and thus Bytebuddy) to mock/spy // classes that are part of the JDK, // and those classes always have bytecode matching the version of the launcher. - // So for example, when using a JDK19 launcher and compiling tests with --release 17, - // Bytebuddy will still encounter classes with Java 19 bytecode. - if ( gradle.ext.javaVersions.test.launcher.asInt() >= 19 ) { + // So for example, when using a JDK22 launcher and compiling tests with --release 21, + // Bytebuddy will still encounter classes with Java 22 bytecode. + if ( jdkVersions.test.launcher.asInt() >= 22 ) { logger.warn( "The version of Java bytecode that will be tested is not supported by Bytebuddy by default. " + " Setting 'net.bytebuddy.experimental=true'." ) systemProperty 'net.bytebuddy.experimental', true @@ -375,6 +318,7 @@ test { // Used in the Travis build so that Travis doesn't end up panicking because there's no output for a long time. testLogging { events "passed", "skipped", "failed" + exceptionFormat = 'full' } } } @@ -454,7 +398,12 @@ task sourcesJar(type: Jar) { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Javadoc -apply from: rootProject.file( 'gradle/javadoc.gradle' ) +tasks.named( "javadoc", Javadoc ) { + configure( options ) { + windowTitle = "Hibernate Javadocs ($project.name)" + docTitle = "Hibernate Javadocs ($project.name : $project.version)" + } +} // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // IDE @@ -505,6 +454,9 @@ checkstyle { // exclude generated java sources - by explicitly setting the base source dir tasks.checkstyleMain.source = 'src/main/java' +tasks.checkstyleMain + .exclude('org/hibernate/jpamodelgen/util/NullnessUtil.java') + .exclude('org/hibernate/internal/util/NullnessUtil.java') // define a second checkstyle task for checking non-fatal violations task nonFatalCheckstyle(type:Checkstyle) { @@ -514,6 +466,36 @@ task nonFatalCheckstyle(type:Checkstyle) { configFile = rootProject.file( 'shared/config/checkstyle/checkstyle-non-fatal.xml' ) } +class CompilerStubsArgumentProvider implements CommandLineArgumentProvider { + + @InputDirectory + @PathSensitive(PathSensitivity.NONE) + File stubsDir + + @Override + Iterable asArguments() { + { return ["-Astubs=${stubsDir}"]} + } +} + +tasks.withType(JavaCompile).configureEach { task -> + // stubs argument needs to be passed as an absolute path, JavaCompile uses the Worker API which changes the current + // working directory and prevents from using a relative path to locate a project file. + // Using a CommandLineArgumentProvider allows build cache hits when the build cache is relocated. + task.options.compilerArgumentProviders.add(new CompilerStubsArgumentProvider(stubsDir: new File(project.rootDir, "checkerstubs"))) +} + +checkerFramework { + checkers = [ + 'org.checkerframework.checker.nullness.NullnessChecker' + ] + extraJavacArgs = [ + '-AsuppressWarnings=initialization', + // stubs is passed directly through options.compilerArgumentProviders + '-AonlyDefs=^org\\.hibernate\\.(jdbc|exception|integrator|jpamodelgen|service|spi|pretty|property\\.access|stat|engine\\.(config|jndi|profile|spi|transaction)|(action|context|bytecode)\\.spi)\\.' + ] +} + task forbiddenApisSystemOut(type: CheckForbiddenApis, dependsOn: compileJava) { bundledSignatures += 'jdk-system-out' @@ -521,7 +503,7 @@ task forbiddenApisSystemOut(type: CheckForbiddenApis, dependsOn: compileJava) { } task forbiddenApisUnsafe(type: CheckForbiddenApis, dependsOn: compileJava) { - bundledSignatures += "jdk-unsafe-${gradle.ext.baselineJavaVersion}".toString() + bundledSignatures += "jdk-unsafe-${jdkVersions.baseline}".toString() // unfortunately we currently have many uses of default Locale implicitly (~370) which need to be fixed // before we can fully enabled this check @@ -532,6 +514,7 @@ task forbiddenApisUnsafe(type: CheckForbiddenApis, dependsOn: compileJava) { task forbiddenApisNonPortable(type: CheckForbiddenApis, dependsOn: compileJava) { bundledSignatures += 'jdk-non-portable' + suppressAnnotations += ['org.hibernate.internal.build.AllowNonPortable'] } task forbiddenApis {