hibernate-orm/build.gradle

438 lines
19 KiB
Groovy
Raw Normal View History

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"
2012-08-22 14:41:16 -04:00
2010-10-08 21:20:10 -04:00
allprojects {
repositories {
2013-04-05 15:30:56 -04:00
mavenCentral()
mavenLocal()
2012-08-08 05:09:11 -04:00
mavenRepo name: 'jboss-nexus', url: "http://repository.jboss.org/nexus/content/groups/public/"
mavenRepo name: "jboss-snapshots", url: "http://snapshots.jboss.org/maven2/"
2010-10-08 21:20:10 -04:00
}
}
buildscript {
repositories {
2013-04-05 15:30:56 -04:00
mavenCentral()
mavenLocal()
2012-08-08 05:09:11 -04:00
mavenRepo name: 'jboss-nexus', url: "http://repository.jboss.org/nexus/content/groups/public/"
mavenRepo name: "jboss-snapshots", url: "http://snapshots.jboss.org/maven2/"
}
dependencies {
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
}
}
2013-05-02 15:44:41 -04:00
ext.hibernateTargetVersion = '4.3.0-SNAPSHOT'
ext.javaLanguageLevel = "1.6"
2013-04-05 15:30:56 -04:00
task wrapper(type: Wrapper) {
gradleVersion = '1.5'
}
idea {
project {
languageLevel = javaLanguageLevel
ipr {
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
def maxHeapSizeConfig = provider.node.component.find { it.@name == 'JavacSettings' }
if( maxHeapSizeConfig == null ){
def javacSettingsNode = provider.node.appendNode('component',[name: 'JavacSettings'])
javacSettingsNode.appendNode('option', [name:"MAXIMUM_HEAP_SIZE", value:"512"])
}
}
beforeMerged { project ->
project.modulePaths.clear()
}
}
}
module {
name = "hibernate-orm"
}
}
// Used in POM customization. Each sub-project overrides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def pomName() {
return "A Hibernate O/RM module"
}
def pomDescription() {
return "A module of the Hibernate O/RM project"
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
2010-10-08 21:20:10 -04:00
// minimize changes, at least for now (gradle uses 'build' by default)..
buildDir = "target"
if ( ! subProject.name.startsWith( 'release' ) && ! subProject.name.startsWith( 'documentation' ) ) {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
2013-01-23 18:22:03 -05:00
apply plugin: 'osgi'
2013-04-08 15:27:47 -04:00
2013-01-23 18:22:03 -05:00
apply from: "../utilities.gradle"
2010-10-08 21:20:10 -04:00
2013-04-08 15:27:47 -04:00
apply plugin: 'findbugs'
apply plugin: 'checkstyle'
apply plugin: 'build-dashboard'
apply plugin: 'project-report'
2010-10-08 21:20:10 -04: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 AnnotationProcessor tool"
}
hibernateJpaModelGenTool {
description = "Dependencies for running the Hibernate JPA Metamodel Generator AnnotationProcessor tool"
}
jaxb {
description = 'Dependencies for running ant xjc (jaxb class generation)'
}
configurations {
all*.exclude group: 'xml-apis', module: 'xml-apis'
}
2010-10-08 21:20:10 -04:00
}
2012-08-08 05:09:11 -04:00
2010-10-08 21:20:10 -04:00
// appropriately inject the common dependencies into each sub-project
dependencies {
compile( libraries.logging )
2013-04-05 15:30:56 -04:00
2010-10-08 21:20:10 -04:00
testCompile( libraries.junit )
testCompile( libraries.byteman )
testCompile( libraries.byteman_install )
testCompile( libraries.byteman_bmunit )
2012-08-08 05:09:11 -04:00
testRuntime( libraries.slf4j_api )
testRuntime( libraries.slf4j_log4j12 )
2010-10-08 21:20:10 -04:00
testRuntime( libraries.jcl_slf4j )
testRuntime( libraries.jcl_api )
testRuntime( libraries.jcl )
testRuntime( libraries.javassist )
2010-10-08 21:20:10 -04:00
testRuntime( libraries.h2 )
2013-04-05 15:30:56 -04:00
jbossLoggingTool( libraries.logging_processor )
2013-04-05 15:30:56 -04:00
hibernateJpaModelGenTool( libraries.jpa_modelgen )
2013-04-05 15:30:56 -04:00
2012-08-08 05:09:11 -04:00
jaxb( libraries.jaxb ){
exclude group: "javax.xml.stream"
}
jaxb( libraries.jaxb2_basics )
jaxb( libraries.jaxb2_ant )
2010-10-08 21:20:10 -04:00
}
2013-04-05 15:30:56 -04:00
// mac-specific stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ext.toolsJar = file("${System.getProperty('java.home')}/../lib/tools.jar")
if ( ext.toolsJar.exists() ) {
2012-08-08 05:09:11 -04:00
dependencies{
testCompile files( toolsJar )
}
}
2013-04-05 15:30:56 -04:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
targetCompatibility = rootProject.javaLanguageLevel
sourceCompatibility = rootProject.javaLanguageLevel
task compile
compile.dependsOn compileJava, processResources, compileTestJava, processTestResources
sourceSets.main {
compileClasspath += configurations.provided
2010-10-08 21:20:10 -04:00
}
sourceSets.all {
2012-08-08 05:09:11 -04:00
ext.originalJavaSrcDirs = java.srcDirs
ext.generatedLoggingSrcDir = file( "${buildDir}/generated-src/logging/${name}" )
java.srcDir generatedLoggingSrcDir
}
2013-04-04 14:01:39 -04:00
task generateMainLoggingClasses(type: JavaCompile) {
ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt/logging" )
classpath = compileJava.classpath + configurations.jbossLoggingTool
source = sourceSets.main.originalJavaSrcDirs
destinationDir = aptDumpDir
options.define(
compilerArgs: [
"-nowarn",
"-proc:only",
"-encoding", "UTF-8",
"-processor", "org.jboss.logging.processor.apt.LoggingToolsProcessor",
"-s", "$sourceSets.main.generatedLoggingSrcDir.absolutePath",
"-AloggingVersion=3.0",
"-source", rootProject.javaLanguageLevel,
"-target", rootProject.javaLanguageLevel,
"-AtranslationFilesPath=${project.rootDir}/src/main/resources"
]
);
outputs.dir sourceSets.main.generatedLoggingSrcDir;
doFirst {
// source = sourceSets.main.originalJavaSrcDirs
sourceSets.main.generatedLoggingSrcDir.mkdirs()
}
doLast {
aptDumpDir.delete()
}
}
// for the time being eat the annoying output from running the annotation processors
generateMainLoggingClasses.logging.captureStandardError(LogLevel.INFO)
task generateSources( type: Task )
generateSources.dependsOn generateMainLoggingClasses
compileJava.dependsOn generateMainLoggingClasses
compileJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
compileTestJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
2013-01-23 18:22:03 -05:00
jar {
Set<String> exportPackages = new HashSet<String>()
Set<String> privatePackages = new HashSet<String>()
2013-04-08 15:27:47 -04:00
2013-01-23 18:22:03 -05:00
// TODO: Could more of this be pulled into utilities.gradle?
sourceSets.each { sourceSet ->
2013-04-08 15:27:47 -04:00
// skip certain source sets
if ( ! ['test','matrix'].contains( sourceSet.name ) ) {
sourceSet.java.each { javaFile ->
// - org.hibernate.boot.registry.classloading.internal
// until EntityManagerFactoryBuilderImpl no longer imports ClassLoaderServiceImpl
// - .util for external module use (especially envers)
final String[] temporaryExports = [
'org.hibernate.boot.registry.classloading.internal',
'org.hibernate.internal.util' ]
final String packageName = determinePackageName( sourceSet.java, javaFile );
if ( ! temporaryExports.contains( packageName )
&& ( packageName.endsWith( ".internal" )
|| packageName.contains( ".internal." )
|| packageName.endsWith( ".test" )
|| packageName.contains( ".test." ) ) ) {
privatePackages.add( packageName );
}
else {
exportPackages.add( packageName );
2013-01-23 18:22:03 -05:00
}
}
2013-04-08 15:27:47 -04:00
}
}
2013-01-23 18:22:03 -05:00
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 *.
'*'
2013-01-23 18:22:03 -05:00
instruction 'Export-Package', exportPackages.toArray(new String[0])
instruction 'Private-Package', privatePackages.toArray(new String[0])
instruction 'Bundle-Vendor', 'Hibernate.org'
2013-01-23 18:22:03 -05:00
instruction 'Implementation-Url', 'http://hibernate.org'
instruction 'Implementation-Version', version
instruction 'Implementation-Vendor', 'Hibernate.org'
instruction 'Implementation-Vendor-Id', 'org.hibernate'
}
}
2010-10-08 21:20:10 -04:00
test {
2012-11-01 01:42:27 -04:00
systemProperties['hibernate.test.validatefailureexpected'] = true
systemProperties += System.properties.findAll { it.key.startsWith( "hibernate.") }
2012-11-01 01:42:27 -04:00
maxHeapSize = "1024m"
// Not strictly needed but useful to attach a profiler:
jvmArgs '-XX:MaxPermSize=256m'
2010-10-08 21:20:10 -04:00
}
processTestResources.doLast( {
copy {
from( sourceSets.test.java.srcDirs ) {
include '**/*.properties'
include '**/*.xml'
2010-10-08 21:20:10 -04:00
}
into sourceSets.test.output.classesDir
}
} )
2010-10-08 21:20:10 -04:00
idea {
module {
iml {
beforeMerged { module ->
module.dependencies.clear()
module.excludeFolders.clear()
}
whenMerged { module ->
module.dependencies*.exported = true
module.excludeFolders += module.pathFactory.path(file(".gradle"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/bundles"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/classes"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/dependency-cache"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/libs"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/reports"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/test-results"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/tmp"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/matrix"))
2012-02-20 03:36:18 -05:00
module.excludeFolders += module.pathFactory.path(file("$buildDir/resources"))
module.excludeFolders -= module.pathFactory.path(file("$buildDir"))
}
}
downloadSources = true
scopes.COMPILE.plus += configurations.provided
}
}
eclipse {
classpath {
plusConfigurations.add( configurations.provided )
}
}
// eclipseClasspath will not add sources to classpath unless the dirs actually exist.
eclipseClasspath.dependsOn("generateSources")
// specialized API/SPI checkstyle tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
task checkstylePublicSources(type: Checkstyle) {
checkstyleClasspath = checkstyleMain.checkstyleClasspath
classpath = checkstyleMain.classpath
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
source subProject.sourceSets.main.originalJavaSrcDirs
// exclude generated sources
exclude '**/generated-src/**'
// because cfg package is a mess mainly from annotation stuff
exclude '**/org/hibernate/cfg/**'
exclude '**/org/hibernate/cfg/*'
// because this should only report on api/spi
exclude '**/internal/**'
exclude '**/internal/*'
ignoreFailures = false
showViolations = true
reports {
xml {
destination "$buildDir/reports/checkstyle/public.xml"
}
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-04-08 15:27:47 -04:00
// Report configs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
checkstyle {
sourceSets = [ subProject.sourceSets.main ]
2013-04-08 15:27:47 -04:00
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
showViolations = false
ignoreFailures = true
}
// exclude generated sources
// unfortunately this nice easy approach does not seem to work : http://forums.gradle.org/gradle/topics/specify_excludes_to_checkstyle_task
//checkstyleMain.exclude '**/generated-src/**'
checkstyleMain.exclude '**/org/hibernate/hql/internal/antlr/**'
checkstyleMain.exclude '**/org/hibernate/hql/internal/antlr/*'
checkstyleMain.exclude '**/org/hibernate/sql/ordering/antlr/*'
checkstyleMain.exclude '**/*_$logger*'
checkstyleMain.exclude '**/org/hibernate/internal/jaxb/**'
// because cfg package is a mess mainly from annotation stuff
checkstyleMain.exclude '**/org/hibernate/cfg/**'
checkstyleMain.exclude '**/org/hibernate/cfg/*'
2013-04-08 15:27:47 -04:00
findbugs {
sourceSets = [ subProject.sourceSets.main, subProject.sourceSets.test ]
2013-04-08 15:27:47 -04:00
ignoreFailures = true
}
// exclude generated sources
// unfortunately this nice easy approach does not seem to work : http://forums.gradle.org/gradle/topics/specify_excludes_to_checkstyle_task
//findbugsMain.exclude '**/generated-src/**'
findbugsMain.exclude '**/org/hibernate/hql/internal/antlr/**'
findbugsMain.exclude '**/org/hibernate/hql/internal/antlr/*'
findbugsMain.exclude '**/org/hibernate/sql/ordering/antlr/*'
findbugsMain.exclude '**/*_$logger*'
findbugsMain.exclude '**/org/hibernate/internal/jaxb/**'
2013-04-08 15:27:47 -04:00
buildDashboard.dependsOn check
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
pom.withXml {
def root = asNode();
root.appendNode( 'name', subProject.pomName() )
root.appendNode( 'description', subProject.pomDescription() )
root.appendNode( 'url', 'http://hibernate.org' )
def org = root.appendNode( 'organization' )
org.appendNode( 'name', 'Hibernate.org' )
org.appendNode( 'url', 'http://hibernate.org' )
def jira = root.appendNode( 'issueManagement' )
jira.appendNode( 'system', 'jira' )
jira.appendNode( 'url', 'https://hibernate.atlassian.net/browse/HHH' )
def scm = root.appendNode( 'scm' )
scm.appendNode( 'url', 'http://github.com/hibernate/hibernate-orm' )
scm.appendNode( 'connection', 'scm:git:http://github.com/hibernate/hibernate-orm.git' )
scm.appendNode( 'developerConnection', 'scm:git:git@github.com:hibernate/hibernate-orm.git' )
def license = root.appendNode( 'licenses' ).appendNode( 'license' );
license.appendNode( 'name', 'GNU Lesser General Public License' )
license.appendNode( 'url', 'http://www.gnu.org/licenses/lgpl-2.1.html' )
license.appendNode( 'comments', 'See discussion at http://hibernate.org/license for more details.' )
license.appendNode( 'distribution', 'repo' )
def dev = root.appendNode( 'developers' ).appendNode( 'developer' );
dev.appendNode( 'id', 'hibernate-team' )
dev.appendNode( 'name', 'The Hibernate Development Team' )
dev.appendNode( 'organization', 'Hibernate.org' )
dev.appendNode( 'organizationUrl', 'http://hibernate.org' )
}
}
}
repositories {
maven {
if ( subProject.version.endsWith( 'SNAPSHOT' ) ) {
name 'jboss-snapshots-repository'
url 'https://repository.jboss.org/nexus/content/repositories/snapshots'
}
else {
name 'jboss-releases-repository'
url 'https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/'
}
2011-06-08 23:39:07 -04:00
}
}
generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
}
}
task sourcesJar(type: Jar, dependsOn: compileJava) {
from sourceSets.main.allSource
classifier = 'sources'
}
2010-10-08 21:20:10 -04:00
}
2010-10-08 21:20:10 -04:00
}