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
|
|
|
|
*/
|
|
|
|
|
2019-05-21 17:29:57 -04:00
|
|
|
|
2020-04-16 06:03:49 -04:00
|
|
|
|
2018-05-12 21:29:50 -04:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
dependencies {
|
2020-04-03 05:01:07 -04:00
|
|
|
classpath 'de.thetaphi:forbiddenapis:2.7'
|
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/base-information.gradle' )
|
|
|
|
apply from: rootProject.file( 'gradle/libraries.gradle' )
|
|
|
|
apply from: rootProject.file( 'gradle/databases.gradle' )
|
|
|
|
|
|
|
|
apply plugin: 'java'
|
2019-10-23 04:03:00 -04:00
|
|
|
apply plugin: 'biz.aQute.bnd.builder'
|
2018-01-10 16:06:58 -05:00
|
|
|
|
|
|
|
apply plugin: 'checkstyle'
|
|
|
|
apply plugin: 'build-dashboard'
|
|
|
|
apply plugin: 'project-report'
|
|
|
|
|
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
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
provided {
|
|
|
|
description = 'Non-exported compile-time dependencies.'
|
|
|
|
}
|
|
|
|
asciidoclet {
|
|
|
|
description = "Dependencies for Asciidoctor Javadoc taglet"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations.all*.exclude group: 'xml-apis', module: 'xml-apis'
|
|
|
|
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
compile libraries.logging
|
|
|
|
|
|
|
|
provided libraries.logging_annotations
|
|
|
|
|
2018-09-04 18:02:26 -04:00
|
|
|
annotationProcessor( libraries.logging_processor )
|
|
|
|
annotationProcessor( libraries.logging )
|
|
|
|
annotationProcessor( libraries.logging_annotations )
|
2018-01-10 16:06:58 -05:00
|
|
|
|
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
|
|
|
|
testCompile( libraries.junit5_api )
|
|
|
|
testRuntime( libraries.junit5_jupiter )
|
|
|
|
testCompile( libraries.junit5_params )
|
2018-01-10 16:06:58 -05:00
|
|
|
testCompile( libraries.junit )
|
2019-05-21 17:29:57 -04:00
|
|
|
testRuntime( libraries.junit5_vintage )
|
|
|
|
|
2018-01-10 16:06:58 -05:00
|
|
|
testCompile( libraries.byteman )
|
|
|
|
testCompile( libraries.byteman_install )
|
|
|
|
testCompile( libraries.byteman_bmunit )
|
|
|
|
|
|
|
|
testRuntime( libraries.log4j )
|
|
|
|
testRuntime( libraries.javassist )
|
|
|
|
testRuntime( libraries.byteBuddy )
|
|
|
|
|
|
|
|
//Databases
|
|
|
|
testRuntime( libraries.h2 )
|
|
|
|
testRuntime( libraries.hsqldb )
|
|
|
|
testRuntime( libraries.postgresql )
|
|
|
|
testRuntime( libraries.mysql )
|
|
|
|
testRuntime( libraries.mariadb )
|
|
|
|
testRuntime( libraries.mssql )
|
|
|
|
testRuntime( libraries.informix )
|
2018-04-04 04:57:25 -04:00
|
|
|
testRuntime( libraries.hana )
|
2018-01-10 16:06:58 -05:00
|
|
|
|
|
|
|
if ( db.equalsIgnoreCase( 'oracle' ) ) {
|
|
|
|
testRuntime( libraries.oracle ) {
|
|
|
|
exclude group: 'com.oracle.jdbc', module: 'xmlparserv2'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( db.equalsIgnoreCase( 'db2' ) ) {
|
|
|
|
testRuntime( libraries.db2 )
|
|
|
|
}
|
|
|
|
else if ( db.equalsIgnoreCase( 'hana' ) ) {
|
|
|
|
testRuntime( libraries.hana )
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mac-specific
|
|
|
|
project.ext.toolsJar = file("${System.getProperty('java.home')}/../lib/tools.jar")
|
|
|
|
if ( project.toolsJar.exists() ) {
|
|
|
|
testCompile files( project.toolsJar )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
// 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
|
|
|
sourceCompatibility = project.baselineJavaVersion
|
|
|
|
targetCompatibility = project.baselineJavaVersion
|
|
|
|
}
|
|
|
|
|
2019-10-23 02:45:47 -04:00
|
|
|
if ( project.baselineJavaVersion != gradle.ext.testedJavaVersion ) {
|
|
|
|
logger.info( "Forcing the target bytecode version for test classes to '$gradle.ext.testedJavaVersion'" )
|
2019-10-21 05:02:11 -04:00
|
|
|
|
|
|
|
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, ...).
|
2019-10-23 02:45:47 -04:00
|
|
|
targetCompatibility = gradle.ext.testedJavaVersion
|
2019-10-21 05:02:11 -04:00
|
|
|
}
|
2018-01-10 16:06:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] )
|
|
|
|
|
|
|
|
sourceSets.main {
|
|
|
|
compileClasspath += configurations.provided
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
File aptDir = file( "${buildDir}/generated-src/apt/${sourceSet.name}" )
|
|
|
|
sourceSet.allJava.srcDir( aptDir )
|
|
|
|
|
|
|
|
javaCompileTask.options.compilerArgs += [
|
|
|
|
"-nowarn",
|
|
|
|
"-encoding", "UTF-8",
|
|
|
|
"-s", "${aptDir.absolutePath}"
|
|
|
|
]
|
|
|
|
|
|
|
|
javaCompileTask.doFirst {
|
|
|
|
aptDir.mkdirs()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
// mac-specific stuff
|
|
|
|
final File toolsJar = file("${System.getProperty('java.home')}/../lib/tools.jar")
|
|
|
|
if ( ext.toolsJar.exists() ) {
|
|
|
|
dependencies{
|
|
|
|
testCompile files( toolsJar )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
// Testing
|
|
|
|
|
2019-05-21 17:29:57 -04:00
|
|
|
tasks.withType( Test.class ).each { test ->
|
|
|
|
test.useJUnitPlatform()
|
|
|
|
|
2018-01-10 16:06:58 -05:00
|
|
|
if ( JavaVersion.current().isJava9Compatible() ) {
|
|
|
|
// Byteman needs this property to be set, https://developer.jboss.org/thread/274997
|
2019-05-21 17:29:57 -04:00
|
|
|
test.jvmArgs += ["-Djdk.attach.allowAttachSelf=true"]
|
2018-01-10 16:06:58 -05:00
|
|
|
}
|
2019-05-21 17:29:57 -04:00
|
|
|
test.jvmArgs += [
|
2018-01-10 16:06:58 -05:00
|
|
|
'-XX:+HeapDumpOnOutOfMemoryError',
|
|
|
|
"-XX:HeapDumpPath=${file( "${buildDir}/OOM-dump.hprof" ).absolutePath}",
|
|
|
|
'-XX:MetaspaceSize=512M'
|
|
|
|
]
|
|
|
|
|
2019-05-21 17:29:57 -04:00
|
|
|
test.maxHeapSize = '4G'
|
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'
|
|
|
|
}
|
2019-09-13 15:30:10 -04:00
|
|
|
|
|
|
|
// todo (6.0) : temporarily include just the new tests so we can publish SNAPSHOTS for others to use
|
|
|
|
test.include 'org/hibernate/orm/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 {
|
|
|
|
inputs.property( "db", db )
|
|
|
|
filter( ReplaceTokens, tokens: dbBundle[db] )
|
2019-02-18 09:14:24 -05:00
|
|
|
}
|
|
|
|
|
2020-04-14 09:21:33 -04:00
|
|
|
// Enable the experimental features of ByteBuddy with JDK 15+
|
|
|
|
test {
|
|
|
|
if ( Integer.valueOf( gradle.ext.testedJavaVersionAsEnum.getMajorVersion() ) >= 15 ) {
|
|
|
|
logger.warn( "The version of java that will be tested is not supported by Bytebuddy by default. " +
|
|
|
|
" 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:06:58 -05:00
|
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
// IDE
|
|
|
|
|
|
|
|
|
|
|
|
//idea {
|
|
|
|
// module {
|
|
|
|
// jdkName = project.sourceCompatibility
|
|
|
|
//
|
|
|
|
// excludeDirs = [file( ".gradle" )]
|
|
|
|
// excludeDirs += file( "$buildDir/classes" )
|
|
|
|
// excludeDirs += file( "$buildDir/bundles" )
|
|
|
|
// excludeDirs += file( "$buildDir/packages" )
|
|
|
|
// excludeDirs += file( "$buildDir/dependency-cache" )
|
|
|
|
// excludeDirs += file( "$buildDir/libs" )
|
|
|
|
// excludeDirs += file( "$buildDir/reports" )
|
|
|
|
// excludeDirs += file( "$buildDir/test-results" )
|
|
|
|
// excludeDirs += file( "$buildDir/tmp" )
|
|
|
|
// excludeDirs += file( "$buildDir/matrix" )
|
|
|
|
// excludeDirs += file( "$buildDir/resources" )
|
|
|
|
//
|
|
|
|
// downloadSources = true
|
|
|
|
// scopes.PROVIDED.plus += [configurations.provided]
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
/*
|
|
|
|
The latest versions of IntelliJ copy and use the test resources into out/test/resources
|
|
|
|
this occurs before the placeholder in the test config file are substituted
|
|
|
|
with the testing values.
|
|
|
|
|
|
|
|
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'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//eclipse {
|
|
|
|
// jdt {
|
|
|
|
// sourceCompatibility = project.sourceCompatibility
|
|
|
|
// targetCompatibility = project.targetCompatibility
|
|
|
|
// }
|
|
|
|
// classpath {
|
|
|
|
// plusConfigurations.add( configurations.provided )
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//// eclipseClasspath will not add sources to classpath unless the dirs actually exist.
|
|
|
|
//// TODO: Eclipse's annotation processor handling is also fairly stupid (and completely lacks in the
|
|
|
|
//// Gradle plugin). For now, just compile first in order to get the logging classes.
|
|
|
|
//eclipseClasspath.dependsOn compile
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
task setDataBase {
|
|
|
|
inputs.property( "db", db )
|
|
|
|
doLast {
|
|
|
|
processTestResources.execute()
|
|
|
|
copyResourcesToIntelliJOutFolder.execute()
|
2018-01-10 16:06:58 -05:00
|
|
|
|
2018-06-01 01:56:13 -04:00
|
|
|
println( 'Setting current database to ' + db )
|
|
|
|
}
|
|
|
|
}
|
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) {
|
|
|
|
classesDirs = project.sourceSets.main.output.classesDirs
|
|
|
|
classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
|
|
|
|
targetCompatibility = project.forbiddenAPITargetJDKCompatibility
|
|
|
|
bundledSignatures += 'jdk-system-out'
|
|
|
|
suppressAnnotations += ['org.hibernate.internal.build.AllowSysOut', 'org.hibernate.internal.build.AllowPrintStacktrace']
|
|
|
|
}
|
|
|
|
|
|
|
|
task forbiddenApisUnsafe(type: CheckForbiddenApis, dependsOn: compileJava) {
|
|
|
|
classesDirs = project.sourceSets.main.output.classesDirs
|
|
|
|
classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
|
|
|
|
targetCompatibility = project.forbiddenAPITargetJDKCompatibility
|
|
|
|
bundledSignatures += "jdk-unsafe-${baselineJavaVersion}".toString()
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
classesDirs = project.sourceSets.main.output.classesDirs
|
|
|
|
classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
|
|
|
|
targetCompatibility = project.forbiddenAPITargetJDKCompatibility
|
|
|
|
bundledSignatures += 'jdk-non-portable'
|
|
|
|
}
|
|
|
|
|
|
|
|
task forbiddenApis
|
|
|
|
project.tasks.withType( CheckForbiddenApis ).each { task -> forbiddenApis.finalizedBy task }
|
|
|
|
|
|
|
|
project.tasks.check.finalizedBy forbiddenApis
|