hibernate-orm/build.gradle

431 lines
13 KiB
Groovy
Raw Normal View History

import org.apache.tools.ant.filters.ReplaceTokens
/*
* 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>.
*/
2010-10-08 21:20:10 -04:00
apply plugin: 'eclipse'
apply plugin: 'idea'
2012-08-08 05:09:11 -04:00
apply from: "./libraries.gradle"
apply from: "./databases.gradle"
2012-08-22 14:41:16 -04:00
2013-04-05 15:30:56 -04:00
buildscript {
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven {
name 'jboss-nexus'
url "http://repository.jboss.org/nexus/content/groups/public/"
}
maven {
name "jboss-snapshots"
url "http://snapshots.jboss.org/maven2/"
}
}
dependencies {
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:2.0.0-SNAPSHOT'
classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0'
classpath 'org.hibernate.build.gradle:gradle-xjc-plugin:1.0.2.Final'
classpath 'com.github.lburgazzoli:lb-karaf-features-gen:1.0.0-SNAPSHOT'
}
2010-10-08 21:20:10 -04:00
}
allprojects {
repositories {
2013-04-05 15:30:56 -04:00
mavenCentral()
mavenLocal()
2013-11-21 14:46:03 -05:00
maven {
name 'jboss-nexus'
url "http://repository.jboss.org/nexus/content/groups/public/"
}
maven {
name "jboss-snapshots"
url "http://snapshots.jboss.org/maven2/"
}
}
}
2013-11-21 14:46:03 -05:00
ext {
2016-06-30 18:20:30 -04:00
hibernateTargetVersion = '5.2.2-SNAPSHOT'
expectedGradleVersion = '3.0-milestone-1'
baselineJavaVersion = '1.8'
2013-11-21 14:46:03 -05:00
osgiExportVersion = hibernateTargetVersion.replaceAll( '-SNAPSHOT', '.SNAPSHOT' )
2013-11-21 14:46:03 -05:00
}
idea {
project {
jdkName = baselineJavaVersion
languageLevel = baselineJavaVersion
vcs = 'Git'
}
module {
name = "hibernate-orm"
}
}
2013-11-26 11:43:50 -05:00
// Used in MANIFEST.MF for OSGi Bundles
def osgiDescription() {
return "A module of the Hibernate O/RM project"
2013-11-26 11:43:50 -05:00
}
2013-12-02 21:53:19 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010-10-08 21:20:10 -04:00
subprojects { subProject ->
apply plugin: 'idea'
apply plugin: 'eclipse'
defaultTasks 'build'
2010-10-08 21:20:10 -04:00
group = 'org.hibernate'
version = rootProject.hibernateTargetVersion
2013-11-21 14:46:03 -05:00
ext.exportPackageVersion = rootProject.osgiExportVersion
2010-10-08 21:20:10 -04:00
// minimize changes, at least for now (gradle uses 'build' by default)..
buildDir = "target"
2013-12-02 21:53:19 -05:00
if ( subProject.name.startsWith( 'release' ) || subProject.name.startsWith( 'documentation' ) ) {
return;
}
if ( subProject.name.startsWith( 'hibernate-orm-modules' ) ) {
return;
}
2013-12-02 21:53:19 -05:00
// everything below here in the closure applies to java projects
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
apply plugin: 'osgi'
apply plugin: 'findbugs'
apply plugin: 'checkstyle'
apply plugin: 'build-dashboard'
apply plugin: 'project-report'
apply plugin: org.hibernate.build.HibernateBuildPlugin
sourceCompatibility = rootProject.baselineJavaVersion
targetCompatibility = rootProject.baselineJavaVersion
2013-12-02 21:53:19 -05:00
configurations {
provided {
// todo : need to make sure these are non-exported
description = 'Non-exported compile-time dependencies.'
}
jbossLoggingTool {
description = 'Dependencies for running the jboss-logging tooling.'
}
2013-12-02 21:53:19 -05:00
configurations {
all*.exclude group: 'xml-apis', module: 'xml-apis'
}
}
// appropriately inject the common dependencies into each sub-project
dependencies {
compile libraries.logging
provided libraries.logging_annotations
jbossLoggingTool( libraries.logging_processor )
2013-12-02 21:53:19 -05:00
testCompile( libraries.junit )
testCompile( libraries.byteman )
testCompile( libraries.byteman_install )
testCompile( libraries.byteman_bmunit )
testRuntime( libraries.log4j )
testRuntime( libraries.javassist )
testRuntime( libraries.woodstox )
//Databases
2013-12-02 21:53:19 -05:00
testRuntime( libraries.h2 )
testRuntime( libraries.hsqldb )
testRuntime( libraries.postgresql )
testRuntime( libraries.mysql )
testRuntime( libraries.mariadb )
testRuntime( libraries.informix )
if (db.equalsIgnoreCase("oracle")) {
dependencies {
testRuntime( libraries.oracle )
}
}
if (db.equalsIgnoreCase("mssql")) {
dependencies {
testRuntime( libraries.mssql )
}
}
2015-05-16 15:23:34 -04:00
// 6.6 gave me some NPE problems from within checkstyle...
checkstyle 'com.puppycrawl.tools:checkstyle:6.5'
2013-12-02 21:53:19 -05:00
}
// mac-specific stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// should really use Jvm.current().toolsJar
2013-12-02 21:53:19 -05:00
ext.toolsJar = file("${System.getProperty('java.home')}/../lib/tools.jar")
if ( ext.toolsJar.exists() ) {
dependencies{
testCompile files( toolsJar )
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// compilation
2013-12-02 21:53:19 -05:00
task compile
compile.dependsOn compileJava, processResources, compileTestJava, processTestResources
sourceSets.main {
compileClasspath += configurations.provided
compileClasspath += configurations.jbossLoggingTool
2013-12-02 21:53:19 -05:00
}
subProject.getConvention().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 = subProject.file( "${subProject.buildDir}/generated-src/apt/${sourceSet.name}" )
sourceSet.allJava.srcDir( aptDir )
javaCompileTask.options.compilerArgs += [
"-nowarn",
"-encoding", "UTF-8",
"-s", "${aptDir.absolutePath}"
]
javaCompileTask.doFirst {
aptDir.mkdirs()
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// testing
subProject.tasks.withType( Test.class ).all { task ->
task.jvmArgs += [
'-XX:+HeapDumpOnOutOfMemoryError',
"-XX:HeapDumpPath=${project.file( "${project.buildDir}/OOM-dump.hprof" ).absolutePath}",
'-XX:MetaspaceSize=512M'
]
task.maxHeapSize = '2G'
task.systemProperties['hibernate.test.validatefailureexpected'] = true
task.systemProperties += System.properties.findAll { it.key.startsWith( "hibernate.") }
// uncomment to help identify pauses in test executions : where they occur
// task.beforeTest { descriptor ->
// println "Starting test: " + descriptor
// }
// task.afterTest { descriptor ->
// println "Completed test: " + descriptor
// }
}
processTestResources.doLast( {
copy {
from( sourceSets.test.java.srcDirs ) {
include '**/*.properties'
include '**/*.xml'
}
into sourceSets.test.output.classesDir
}
copy {
ext.targetDir = file( "${buildDir}/resources/test" )
from file('src/test/resources')
into targetDir
filter( ReplaceTokens, tokens: dbBundle[db] );
}
} )
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// artifact
2013-12-02 21:53:19 -05:00
jar {
manifest = osgiManifest {
// GRADLE-1411: Even if we override Imports and Exports
// auto-generation with instructions, classesDir and classpath
// need to be here (temporarily).
classesDir = sourceSets.main.output.classesDir
classpath = configurations.runtime
instruction '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)"',
// Tell Gradle OSGi to still dynamically import the other packages.
// IMPORTANT: Do not include the * in the modules' .gradle files.
// If it exists more than once, the manifest will physically contain a *.
'*'
instruction 'Bundle-Vendor', 'Hibernate.org'
instruction 'Bundle-Description', subProject.osgiDescription()
instruction 'Implementation-Url', 'http://hibernate.org'
instruction 'Implementation-Version', version
instruction 'Implementation-Vendor', 'Hibernate.org'
instruction 'Implementation-Vendor-Id', 'org.hibernate'
2016-03-02 21:07:16 -05:00
instruction 'Implementation-Title', name
instruction 'Specification-Title', name
instruction 'Specification-Version', version
instruction 'Specification-Vendor', 'Hibernate.org'
2013-12-02 21:53:19 -05:00
}
}
task sourcesJar(type: Jar, dependsOn: compileJava) {
from sourceSets.main.allSource
classifier = 'sources'
}
sourcesJar {
manifest = jar.manifest
2013-12-02 21:53:19 -05:00
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-12-02 21:53:19 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// IDE options
2013-12-02 21:53:19 -05:00
idea {
module {
jdkName = subProject.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" )
2013-12-02 21:53:19 -05:00
downloadSources = true
scopes.PROVIDED.plus += [configurations.provided]
2013-12-02 21:53:19 -05:00
}
}
eclipse {
jdt {
sourceCompatibility = subProject.sourceCompatibility
targetCompatibility = subProject.targetCompatibility
}
2013-12-02 21:53:19 -05:00
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
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-12-02 21:53:19 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Report configs
2013-12-02 21:53:19 -05:00
checkstyle {
sourceSets = [ subProject.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'
2013-12-02 21:53:19 -05:00
findbugs {
sourceSets = [ subProject.sourceSets.main, subProject.sourceSets.test ]
ignoreFailures = true
toolVersion = '3.0.1'
2015-04-20 13:00:12 -04:00
// for now we need to set this to low so that FindBugs will actually report the DM_CONVERT_CASE warning we care about
reportLevel = 'low'
// remove all low level bug warnings except DM_CONVERT_CASE
excludeFilterConfig=resources.text.fromString(excludeAllLowLevelBugsExcept('DM_CONVERT_CASE'))
2013-12-02 21:53:19 -05:00
}
2015-04-20 13:00:12 -04:00
// exclude generated java sources and cfg package is a mess mainly from annotation stuff
findbugsMain.doFirst {
classes = classes.filter {
!it.path.contains( 'org/hibernate/hql/internal/antlr' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/cfg/spi' ) &&
!it.path.contains( 'org/hibernate/sql/ordering/antlr/Generated' ) &&
!it.path.contains( 'org/hibernate/sql/ordering/antlr/OrderByTemplateTokenTypes' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/Jaxb' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/Adapter' ) &&
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/ObjectFactory' ) &&
!it.path.contains( 'org/hibernate/cfg' ) &&
!it.path.contains( '_\$logger' )
}
}
2015-04-20 13:00:12 -04:00
// because cfg package is a mess mainly from annotation stuff
2015-04-20 13:00:12 -04:00
checkstyleMain.exclude '**/org/hibernate/cfg/**'
checkstyleMain.exclude '**/org/hibernate/cfg/*'
2013-12-02 21:53:19 -05:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Publishing
2013-12-02 21:53:19 -05:00
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact( sourcesJar ) {
classifier 'sources'
2013-12-02 21:53:19 -05:00
}
}
// http://issues.gradle.org/browse/GRADLE-2966
// Once ^^ is resolved:
// 1) Move hibernate-testing module into hibernate-core tests
// 2) Define a second publication on hibernate-core for publishing the testing jar
// We could kind of do this now, but it would just be the jar. Every module would still need
// to duplicate the testing dependencies. Well, on second thought, we could centralize the
// testing dependencies here within the subprojects block
2013-12-02 21:53:19 -05:00
}
}
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file( "$subProject.buildDir/generated-pom.xml" )
2013-12-02 21:53:19 -05:00
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-12-02 21:53:19 -05:00
2010-10-08 21:20:10 -04:00
}
task release(type: Task, dependsOn: 'release:release')
2013-11-21 14:46:03 -05:00
task wrapper(type: Wrapper) {
gradleVersion = expectedGradleVersion
}
def excludeAllLowLevelBugsExcept(String[] bugTypes){
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer);
xml.FindBugsFilter {
Match {
Confidence( value: '3' )
bugTypes.each { bug ->
Not {
Bug( pattern: "${bug}" )
}
}
}
}
return writer.toString( )
}