hibernate-orm/hibernate-entitymanager/hibernate-entitymanager.gradle

147 lines
5.3 KiB
Groovy

import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: "jdocbook"
apply plugin: org.hibernate.build.gradle.testing.matrix.MatrixTestingPlugin
buildscript {
repositories {
mavenCentral()
mavenLocal()
mavenRepo name: "jboss", urls: "http://repository.jboss.org/nexus/content/groups/public/"
}
dependencies {
classpath 'org.jboss.jdocbook:gradle-jdocbook:1.1.0'
}
}
dependencies {
compile( project(':hibernate-core') )
compile( libraries.dom4j )
compile( libraries.commons_annotations )
compile( libraries.jpa )
compile( libraries.jta )
compile( libraries.javassist )
testCompile( project(':hibernate-testing') )
testCompile( libraries.junit )
testCompile( libraries.shrinkwrap_api )
testCompile( libraries.shrinkwrap )
testCompile( libraries.validation )
testRuntime( libraries.validator )
jdocbookStyles "org.hibernate:hibernate-jdocbook-style:2.0.1"
}
sourceSets {
matrix {
java {
srcDir 'src/matrix/java'
}
resources {
srcDir 'src/matrix/resources'
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// JPA model-gen set up
////////////////////////////////////////////////////////////////////////////////////////////////////////
aptDumpDir = file( buildDirName + "/tmp/apt" )
////////////////////////////////////////////////////////////////////////////////////////////////////////
// 'test' sourceSet specific JPA model-gen set up
////////////////////////////////////////////////////////////////////////////////////////////////////////
sourceSets.test {
originalJavaSrcDirs = java.srcDirs
generatedJpaMetamodelSrcDir = file( "${buildDir}/generated-src/jpamodelgen/${name}" )
java.srcDir generatedJpaMetamodelSrcDir
}
task generateTestJpaMetamodelClasses(type: Compile) {
classpath = compileTestJava.classpath + configurations.hibernateJpaModelGenTool
source = sourceSets.test.originalJavaSrcDirs
destinationDir = aptDumpDir
options.define(
compilerArgs: [
"-proc:only",
"-processor", "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor",
"-s", "$sourceSets.test.generatedJpaMetamodelSrcDir.absolutePath"
]
);
outputs.dir sourceSets.test.generatedJpaMetamodelSrcDir;
doFirst {
sourceSets.test.generatedJpaMetamodelSrcDir.mkdirs()
}
}
// for the time being eat the annoying output from running the annotation processors
generateTestJpaMetamodelClasses.logging.captureStandardError(LogLevel.INFO)
compileTestJava.dependsOn generateTestJpaMetamodelClasses
compileTestJava.options.define(compilerArgs: ["-proc:none"])
////////////////////////////////////////////////////////////////////////////////////////////////////////
// 'matrix' sourceSet specific JPA model-gen set up
////////////////////////////////////////////////////////////////////////////////////////////////////////
sourceSets.matrix {
originalJavaSrcDirs = java.srcDirs
generatedJpaMetamodelSrcDir = file( "${buildDir}/generated-src/jpamodelgen/${name}" )
java.srcDir generatedJpaMetamodelSrcDir
}
task generateMatrixJpaMetamodelClasses(type: Compile) {
classpath = compileMatrixJava.classpath + configurations.hibernateJpaModelGenTool
source = sourceSets.matrix.java
destinationDir = aptDumpDir
options.define(
compilerArgs: [
"-proc:only",
"-processor", "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor",
"-s", "$sourceSets.matrix.generatedJpaMetamodelSrcDir.absolutePath"
]
);
outputs.dir sourceSets.matrix.generatedJpaMetamodelSrcDir;
doFirst {
sourceSets.matrix.generatedJpaMetamodelSrcDir.mkdirs()
}
}
// for the time being eat the annoying output from running the annotation processors
generateMatrixJpaMetamodelClasses.logging.captureStandardError(LogLevel.INFO)
compileMatrixJava.dependsOn generateMatrixJpaMetamodelClasses
compileMatrixJava.options.define(compilerArgs: ["-proc:none", "-encoding", "UTF-8"])
bundlesTargetDir = file( "$buildDirName/bundles" )
task copyBundleResources (type: Copy) {
from file('src/test/bundles')
into bundlesTargetDir
filter(ReplaceTokens, tokens: [
buildDirName: buildDir.absolutePath,
'db.dialect': 'org.hibernate.dialect.H2Dialect',
'jdbc.driver': 'org.h2.Driver',
'jdbc.user': 'sa',
'jdbc.pass': '',
'jdbc.url': 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE',
]);
doFirst {
bundlesTargetDir.mkdirs()
}
}
// make sure that the bundles for the packaged test (PackagingTestCase) are copied as well
processTestResources.dependsOn copyBundleResources
jdocbook {
format('html_single') {
finalName = "index.html"
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl"
}
format('html') {
finalName = "index.html"
stylesheet = "classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl"
}
masterSourceDocumentName="master.xml"
masterLanguage="en"
}
ideaModule {
excludeDirs += file("$buildDir/bundles")
testSourceDirs += file( 'src/matrix/java')
testSourceDirs += file( 'src/matrix/resources')
}