2018-01-10 16:06:58 -05:00
/ *
* Hibernate , Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License ( LGPL ) , version 2.1 or later
* See the lgpl . txt file in the root directory or http: //www.gnu.org/licenses/lgpl-2.1.html
* /
2018-05-12 21:29:50 -04:00
2018-01-10 16:06:58 -05:00
/ * *
* Support for modules that contain Java code
* /
2018-05-12 21:29:50 -04:00
buildscript {
repositories {
mavenCentral ( )
}
dependencies {
2021-06-26 09:46:09 -04:00
classpath 'de.thetaphi:forbiddenapis:3.1'
2018-05-12 21:29:50 -04:00
}
}
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
2019-05-21 17:29:57 -04:00
import org.apache.tools.ant.filters.ReplaceTokens
2018-01-10 16:06:58 -05:00
apply from: rootProject . file ( 'gradle/libraries.gradle' )
apply from: rootProject . file ( 'gradle/databases.gradle' )
2021-05-14 15:59:59 -04:00
apply plugin: 'java-library'
2021-06-26 09:46:09 -04:00
apply plugin: 'org.hibernate.orm.database-service'
2018-01-10 16:06:58 -05:00
apply plugin: 'checkstyle'
apply plugin: 'build-dashboard'
apply plugin: 'project-report'
2021-05-14 15:59:59 -04:00
2020-04-16 06:03:49 -04:00
// Attempt to leverage JetBrain's Gradle extension to automatically define
2019-05-21 17:29:57 -04:00
// `copyResourcesToIntelliJOutFolder` as a "build trigger" on import.
//
// However, see https://github.com/JetBrains/gradle-idea-ext-plugin/issues/8
apply plugin: 'org.jetbrains.gradle.plugin.idea-ext'
2018-01-10 16:06:58 -05:00
ext {
java9ModuleNameBase = project . name . startsWith ( 'hibernate-' ) ? name . drop ( 'hibernate-' . length ( ) ) : name
java9ModuleName = "org.hibernate.orm.$project.java9ModuleNameBase"
2018-10-15 05:56:27 -04:00
forbiddenAPITargetJDKCompatibility = '11'
2018-01-10 16:06:58 -05:00
}
2020-04-06 13:21:11 -04:00
if ( ! project . description ) {
project . description = "The Hibernate ORM $project.name module"
2018-01-10 16:06:58 -05:00
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Configurations and Dependencies
2021-09-22 18:52:06 -04:00
configurations . all {
resolutionStrategy {
dependencySubstitution {
// will handle dependencies pulled in transitively
substitute module ( 'javax.persistence:javax.persistence-api' ) with module ( libraries . jakarta_jpa )
substitute module ( 'javax.transaction:jta' ) with module ( libraries . jakarta_jta )
substitute module ( 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec' ) with module ( libraries . jakarta_jta )
substitute module ( 'javax.validation:validation-api' ) with module ( libraries . jakarta_validation )
substitute module ( 'javax.interceptor:javax.interceptor-api' ) with module ( libraries . jakarta_interceptor )
substitute module ( 'javax.activation:javax.activation-api' ) with module ( libraries . jakarta_activation )
substitute module ( 'javax.enterprise:cdi-api' ) with module ( libraries . jakarta_cdi )
substitute module ( 'org.jboss.weld.se:weld-se-shaded' ) with module ( libraries . jakarta_weld )
substitute module ( 'javax.xml.bind:jaxb-api' ) with module ( libraries . jakarta_jaxb_api )
substitute module ( 'org.glassfish.jaxb:jaxb-runtime' ) with module ( libraries . jakarta_jaxb_runtime )
substitute module ( 'org.jboss.narayana.jta:narayana-jta' ) with module ( libraries . jboss_jta_jakarta )
substitute module ( 'org.jboss:jboss-transaction-spi' ) with module ( libraries . jboss_tx_spi_jakarta )
substitute module ( 'org.hibernate.validator:hibernate-validator' ) with module ( libraries . jakarta_validator )
substitute module ( 'org.glassfish:javax.el' ) with module ( libraries . jakarta_el )
}
}
exclude group: 'xml-apis' , module: 'xml-apis'
}
2018-01-10 16:06:58 -05:00
dependencies {
2021-05-14 15:59:59 -04:00
implementation libraries . logging
2019-05-21 17:29:57 -04:00
2021-05-14 15:59:59 -04:00
compileOnly libraries . logging_annotations
2019-05-21 17:29:57 -04:00
// JUnit dependencies made up of:
// * JUnit 5
// * the Jupiter engine which runs JUnit 5 based tests
// * the "vintage" engine - which runs JUnit 3 and 4 based tests
2021-05-14 15:59:59 -04:00
testImplementation libraries . junit5_api
testImplementation libraries . junit5_jupiter
testImplementation libraries . junit5_params
testImplementation libraries . junit
testImplementation libraries . junit5_vintage
2019-05-21 17:29:57 -04:00
2021-05-14 15:59:59 -04:00
testImplementation libraries . byteman
testImplementation libraries . byteman_install
testImplementation libraries . byteman_bmunit
2018-01-10 16:06:58 -05:00
2021-05-31 08:55:18 -04:00
testRuntimeOnly libraries . log4j2
2021-05-14 15:59:59 -04:00
testRuntimeOnly libraries . byteBuddy
2018-01-10 16:06:58 -05:00
//Databases
2021-05-14 15:59:59 -04:00
testRuntimeOnly libraries . h2
testRuntimeOnly libraries . derby
testRuntimeOnly libraries . hsqldb
testRuntimeOnly libraries . postgresql
testRuntimeOnly libraries . mysql
testRuntimeOnly libraries . mariadb
testRuntimeOnly libraries . mssql
testRuntimeOnly libraries . informix
testRuntimeOnly libraries . cockroachdb
testRuntimeOnly libraries . oracle
2021-06-23 08:56:57 -04:00
testRuntimeOnly libraries . sybase
2021-02-03 04:55:07 -05:00
// 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+
if ( db . startsWith ( 'db2' ) ) {
2021-05-14 15:59:59 -04:00
testRuntimeOnly libraries . db2
2018-01-10 16:06:58 -05:00
}
2021-02-03 04:55:07 -05:00
else if ( db . startsWith ( 'hana' ) ) {
2021-05-14 15:59:59 -04:00
testRuntimeOnly libraries . hana
2018-01-10 16:06:58 -05:00
}
2021-05-14 15:59:59 -04:00
annotationProcessor libraries . logging_processor
annotationProcessor libraries . logging
annotationProcessor libraries . logging_annotations
2022-01-11 16:47:13 -05:00
constraints {
implementation ( 'org.apache.logging.log4j:log4j-core' ) {
version {
2022-01-12 09:37:16 -05:00
strictly ( '[2.17.1, 3[' )
prefer ( '2.17.1' )
2022-01-11 16:47:13 -05:00
}
2022-01-12 09:37:16 -05:00
because ( 'CVE-2021-44228, CVE-2021-45046, CVE-2021-45105, CVE-2021-44832: Log4j vulnerable to remote code execution and other critical security vulnerabilities' )
2022-01-11 16:47:13 -05:00
}
}
2018-01-10 16:06:58 -05:00
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Compilation
2019-10-21 05:02:11 -04:00
tasks . withType ( JavaCompile ) {
2018-01-10 16:06:58 -05:00
options . encoding = 'UTF-8'
2019-10-21 05:02:11 -04:00
}
2020-11-09 04:13:34 -05:00
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 {
2021-11-26 11:24:34 -05:00
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" ] )
2020-11-09 04:13:34 -05:00
}
tasks . compileTestJava . configure {
2021-11-26 11:24:34 -05:00
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" ] )
2020-11-09 04:13:34 -05:00
}
2019-10-21 05:02:11 -04:00
2020-11-09 04:13:34 -05:00
// Configure version of Java tools
java {
toolchain {
languageVersion = gradle . ext . javaVersions . main . compiler
}
}
2019-10-21 05:02:11 -04:00
tasks . compileTestJava {
2020-11-09 04:13:34 -05:00
javaCompiler = javaToolchains . compilerFor {
languageVersion = gradle . ext . javaVersions . test . compiler
}
}
2020-11-09 06:09:02 -05:00
// Configure JVM Options
tasks . withType ( JavaCompile ) . configureEach {
options . forkOptions . jvmArgs . addAll ( getProperty ( 'toolchain.compiler.jvmargs' ) . toString ( ) . split ( ' ' ) )
}
tasks . withType ( Javadoc ) . configureEach {
options . setJFlags ( getProperty ( 'toolchain.javadoc.jvmargs' ) . toString ( ) . split ( ' ' ) . toList ( ) . findAll ( { ! it . isEmpty ( ) } ) )
}
2020-11-09 04:13:34 -05:00
// Display version of Java tools
tasks . withType ( JavaCompile ) . configureEach {
doFirst {
logger . lifecycle "Compiling with '${javaCompiler.get().metadata.installationPath}'"
}
}
tasks . withType ( Javadoc ) . configureEach {
doFirst {
logger . lifecycle "Generating javadoc with '${javadocTool.get().metadata.installationPath}'"
}
2019-10-21 05:02:11 -04:00
}
2018-01-10 16:06:58 -05:00
}
task compile ( dependsOn: [ compileJava , processResources , compileTestJava , processTestResources ] )
2021-08-02 17:35:16 -04:00
2018-01-10 16:06:58 -05:00
convention . findPlugin ( JavaPluginConvention . class ) . sourceSets . each { sourceSet - >
JavaCompile javaCompileTask = project . tasks . findByName ( sourceSet . compileJavaTaskName ) as JavaCompile
// NOTE : this aptDir stuff is needed until we can have IntelliJ run annotation processors for us
// which cannot happen until we can fold hibernate-testing back into hibernate-core/src/test
// which cannot happen until... ugh
javaCompileTask . options . compilerArgs + = [
"-nowarn" ,
2021-08-02 17:35:16 -04:00
"-encoding" , "UTF-8"
2018-01-10 16:06:58 -05:00
]
}
2021-09-29 12:50:55 -04:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attach tools JAR to the classpath for byteman tests
final File toolsJar = file ( "${System.getProperty('java.home')}/../lib/tools.jar" )
if ( toolsJar . exists ( ) ) {
dependencies {
2021-10-13 04:24:56 -04:00
testImplementation files ( toolsJar )
2021-09-29 12:50:55 -04:00
}
}
2018-01-10 16:06:58 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Testing
2020-11-09 04:13:34 -05:00
if ( gradle . ext . javaToolchainEnabled ) {
tasks . test {
// Configure version of Java tools
javaLauncher = javaToolchains . launcherFor {
languageVersion = gradle . ext . javaVersions . test . launcher
}
2020-11-09 06:09:02 -05:00
// Configure JVM Options
2020-12-14 06:10:10 -05:00
jvmArgs ( getProperty ( 'toolchain.launcher.jvmargs' ) . toString ( ) . split ( ' ' ) )
2020-11-09 06:09:02 -05:00
2020-11-09 04:13:34 -05:00
// Display version of Java tools
doFirst {
logger . lifecycle "Testing with '${javaLauncher.get().metadata.installationPath}'"
}
}
}
2021-08-26 12:36:51 -04:00
class HeapDumpPathProvider implements CommandLineArgumentProvider {
2021-09-23 16:01:29 -04:00
@OutputDirectory
Provider < Directory > path
2021-08-26 12:36:51 -04:00
@Override
Iterable < String > asArguments ( ) {
[ "-XX:HeapDumpPath=${path.get().asFile.absolutePath}" ]
}
}
2020-11-09 04:13:34 -05:00
2019-05-21 17:29:57 -04:00
tasks . withType ( Test . class ) . each { test - >
test . useJUnitPlatform ( )
2021-06-26 09:46:09 -04:00
test . usesService ( project . gradle . sharedServices . registrations . getByName ( 'databaseService' ) . service )
2021-11-26 11:24:34 -05:00
// Byteman needs this property to be set, https://developer.jboss.org/thread/274997
test . jvmArgs + = [ "-Djdk.attach.allowAttachSelf=true" ]
2021-08-26 12:36:51 -04:00
test . jvmArgumentProviders . add (
2021-09-23 16:01:29 -04:00
new HeapDumpPathProvider ( path: project . layout . buildDirectory . dir ( "OOM-dump" ) )
2021-08-26 12:36:51 -04:00
)
2019-05-21 17:29:57 -04:00
test . jvmArgs + = [
2018-01-10 16:06:58 -05:00
'-XX:+HeapDumpOnOutOfMemoryError' ,
2020-10-25 17:57:55 -04:00
'-XX:MetaspaceSize=256M'
2018-01-10 16:06:58 -05:00
]
2020-10-27 10:24:37 -04:00
test . maxHeapSize = '3G'
2018-01-10 16:06:58 -05:00
2019-05-21 17:29:57 -04:00
test . systemProperties [ 'hibernate.test.validatefailureexpected' ] = true
test . systemProperties + = System . properties . findAll { it . key . startsWith ( "hibernate." ) }
test . enableAssertions = true
2020-04-16 06:03:49 -04:00
2019-05-21 17:29:57 -04:00
if ( project . name ! = 'hibernate-testing' ) {
test . dependsOn ':hibernate-testing:test'
}
2018-01-10 16:06:58 -05:00
}
2019-05-21 17:29:57 -04:00
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'
include '*.xml'
include '**/*.properties'
include '**/*.xml'
}
2018-01-10 16:06:58 -05:00
}
}
}
}
2019-05-21 17:29:57 -04:00
processTestResources {
2021-10-13 04:24:56 -04:00
duplicatesStrategy DuplicatesStrategy . INCLUDE
2019-05-21 17:29:57 -04:00
inputs . property ( "db" , db )
2021-09-29 12:50:55 -04:00
doLast {
copy {
from ( sourceSets . test . java . srcDirs ) {
include '**/*.properties'
include '**/*.xml'
}
2021-12-01 12:50:10 -05:00
into sourceSets . test . java . classesDirectory
2021-09-29 12:50:55 -04:00
}
copy {
from file ( 'src/test/resources' )
into file ( "${buildDir}/resources/test" )
exclude 'src/test/resources/hibernate.properties'
}
copy {
from file ( 'src/test/resources/hibernate.properties' )
into file ( "${buildDir}/resources/test" )
filter ( ReplaceTokens , tokens: dbBundle [ db ] )
}
}
2019-02-18 09:14:24 -05:00
}
2020-05-27 12:22:54 -04:00
// Keep system properties in sync with gradle.properties!
test {
systemProperty 'user.language' , 'en'
systemProperty 'user.country' , 'US'
systemProperty 'user.timezone' , 'UTC'
systemProperty 'file.encoding' , 'UTF-8'
2021-02-09 07:03:18 -05:00
// Needed for AdoptOpenJDK on alpine? The problem is similar to this: https://github.com/mockito/mockito/issues/978
jvmArgs '-XX:+StartAttachListener'
2020-05-27 12:22:54 -04:00
}
2021-07-05 09:29:43 -04:00
// Enable the experimental features of ByteBuddy with JDK 19+
2020-04-14 09:21:33 -04:00
test {
2021-07-05 09:29:43 -04:00
if ( gradle . ext . javaVersions . test . release . asInt ( ) > = 19 ) {
2020-11-09 04:13:34 -05:00
logger . warn ( "The version of Java bytecode that will be tested is not supported by Bytebuddy by default. " +
2020-04-14 09:21:33 -04:00
" Setting 'net.bytebuddy.experimental=true'." )
systemProperty 'net.bytebuddy.experimental' , true
}
}
2019-05-27 07:02:38 -04:00
test {
2019-06-13 02:44:53 -04:00
if ( project . findProperty ( 'log-test-progress' ) ? . toString ( ) ? . toBoolean ( ) ) {
// Log a statement for each 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"
}
2019-05-27 07:02:38 -04:00
}
}
2021-05-18 17:03:34 -04:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Artifacts (jar, sources, javadoc)
ext {
java9ModuleNameBase = project . name . startsWith ( 'hibernate-' ) ? name . drop ( 'hibernate-' . length ( ) ) : name
java9ModuleName = "org.hibernate.orm.$project.java9ModuleNameBase"
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Jar
jar {
manifest {
attributes (
// Basic JAR manifest attributes
'Specification-Title' : project . name ,
'Specification-Version' : project . version ,
'Specification-Vendor' : 'Hibernate.org' ,
'Implementation-Title' : project . name ,
'Implementation-Version' : project . version ,
'Implementation-Vendor' : 'Hibernate.org' ,
'Implementation-Vendor-Id' : 'org.hibernate' ,
2021-06-07 06:47:53 -04:00
'Implementation-Url' : 'https://hibernate.org/orm' ,
2021-05-18 17:03:34 -04:00
// Java 9 module name
'Automatic-Module-Name' : project . java9ModuleName ,
// Hibernate-specific JAR manifest attributes
'Hibernate-VersionFamily' : project . ormVersion . family ,
'Hibernate-JpaVersion' : project . jpaVersion . name ,
// BND Plugin instructions (for OSGi):
2021-07-26 14:51:22 -04:00
'-reproducible' : true ,
'-noextraheaders' : true ,
2021-05-18 17:03:34 -04:00
'Bundle-Name' : project . name ,
'Bundle-SymbolicName' : project . java9ModuleName ,
'Bundle-Vendor' : 'Hibernate.org' ,
2021-06-07 06:47:53 -04:00
'Bundle-DocURL' : "https://www.hibernate.org/orm/${project.ormVersion.family}" ,
2021-05-18 17:03:34 -04:00
// This is overridden in some sub-projects
'Import-Package' : [
// Temporarily support JTA 1.1 -- Karaf and other frameworks still
// use it. Without this, the plugin generates [1.2,2).
'javax.transaction;version="[1.1,2)"' ,
// Also import every package referenced in the code
// (note that '*' is resolved at build time to a list of packages)
'*'
] . join ( ',' ) ,
'-exportcontents' : "*;version=${project.version}"
)
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// sources
task sourcesJar ( type: Jar ) {
from project . sourceSets . main . allSource
manifest {
attributes (
// Basic JAR manifest attributes
'Specification-Title' : project . name ,
'Specification-Version' : project . version ,
'Specification-Vendor' : 'Hibernate.org' ,
'Implementation-Title' : project . name ,
'Implementation-Version' : project . version ,
'Implementation-Vendor' : 'Hibernate.org' ,
'Implementation-Vendor-Id' : 'org.hibernate' ,
2021-06-07 06:47:53 -04:00
'Implementation-Url' : 'https://hibernate.org/orm' ,
2021-05-18 17:03:34 -04:00
// Hibernate-specific JAR manifest attributes
'Hibernate-VersionFamily' : project . ormVersion . family ,
'Hibernate-JpaVersion' : project . jpaVersion . name
)
}
archiveClassifier . set ( 'sources' )
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Javadoc
apply from: rootProject . file ( 'gradle/javadoc.gradle' )
2018-01-10 16:06:58 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// IDE
/ *
2021-06-26 09:46:09 -04:00
The latest versions of IntelliJ copy the test resources into out /test/ resources and
use those for its test classpath . Unfortunately , this occurs before the placeholder
in the test config file are substituted with the testing values .
2018-01-10 16:06:58 -05:00
This behaviour prevents the execution of the hibernate tests from inside the IDE .
A solution is to enable the 'After Build' Execution of the copyResourcesToIntelliJOutFolder task
from the 'Gradle project' IntelliJ tool window ( The task can be found under hibernate - orm > Task > other )
* /
2019-05-21 17:29:57 -04:00
task copyResourcesToIntelliJOutFolder ( type: Task , dependsOn: project . tasks . processTestResources ) {
2018-01-10 16:06:58 -05:00
doLast {
copy {
from "$buildDir/resources/test"
into 'out/test/resources'
}
}
}
2021-06-26 09:46:09 -04:00
2018-01-10 16:06:58 -05:00
2018-06-01 01:56:13 -04:00
/ *
Use this task to set the current DB in a given module .
> gradlew sDB - Pdb = mysql
Afterward , you can run any test from the IDE against that particular DB .
* /
2020-09-01 05:31:22 -04:00
task setDataBase dependsOn ( processTestResources , copyResourcesToIntelliJOutFolder ) {
println ( 'Setting current database to ' + db )
2018-06-01 01:56:13 -04:00
}
2018-01-10 16:06:58 -05:00
2020-09-01 05:31:22 -04:00
copyResourcesToIntelliJOutFolder . mustRunAfter processTestResources
2018-01-10 16:06:58 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Report configs
checkstyle {
sourceSets = [ project . sourceSets . main ]
configFile = rootProject . file ( 'shared/config/checkstyle/checkstyle.xml' )
showViolations = false
}
// exclude generated java sources - by explicitly setting the base source dir
checkstyleMain . source = 'src/main/java'
// define a second checkstyle task for checking non-fatal violations
task nonFatalCheckstyle ( type: Checkstyle ) {
source = project . sourceSets . main . java
classpath = project . configurations . checkstyle
showViolations = false
configFile = rootProject . file ( 'shared/config/checkstyle/checkstyle-non-fatal.xml' )
}
// because cfg package is a mess mainly from annotation stuff
checkstyleMain . exclude '**/org/hibernate/cfg/**'
checkstyleMain . exclude '**/org/hibernate/cfg/*'
2020-04-16 06:46:19 -04:00
task forbiddenApisSystemOut ( type: CheckForbiddenApis , dependsOn: compileJava ) {
bundledSignatures + = 'jdk-system-out'
suppressAnnotations + = [ 'org.hibernate.internal.build.AllowSysOut' , 'org.hibernate.internal.build.AllowPrintStacktrace' ]
}
task forbiddenApisUnsafe ( type: CheckForbiddenApis , dependsOn: compileJava ) {
2020-11-09 04:13:34 -05:00
bundledSignatures + = "jdk-unsafe-${gradle.ext.baselineJavaVersion}" . toString ( )
2020-04-16 06:46:19 -04:00
// unfortunately we currently have many uses of default Locale implicitly (~370) which need to be fixed
// before we can fully enabled this check
//
// No idea how findbugs was missing these b4
ignoreFailures = true
}
task forbiddenApisNonPortable ( type: CheckForbiddenApis , dependsOn: compileJava ) {
bundledSignatures + = 'jdk-non-portable'
2021-06-26 09:46:09 -04:00
}
2020-04-23 06:48:32 -04:00
2021-06-26 09:46:09 -04:00
task forbiddenApis
project . tasks . withType ( CheckForbiddenApis ) . each { task - >
task . outputs . dirs project . sourceSets . main . output . classesDirs
task . classesDirs = project . sourceSets . main . output . classesDirs
task . classpath = project . sourceSets . main . compileClasspath + project . sourceSets . main . runtimeClasspath
task . targetCompatibility = project . forbiddenAPITargetJDKCompatibility
2020-04-23 06:48:32 -04:00
// This slows down the checks a little, but is necessary to avoid the gradle deamon holding on
// to class definitions loaded previously - even possibly in a previous build.
2021-06-26 09:46:09 -04:00
task . disableClassloadingCache = true
2020-04-16 06:46:19 -04:00
2021-06-26 09:46:09 -04:00
tasks . forbiddenApis . finalizedBy task
}
2020-04-16 06:46:19 -04:00
2021-06-26 09:46:09 -04:00
project . tasks . check . finalizedBy tasks . forbiddenApis