hibernate-orm/tooling/metamodel-generator/hibernate-jpamodelgen.gradle

75 lines
1.7 KiB
Groovy

apply plugin: 'version-injection'
dependencies {
testCompile libraries.junit
testCompile libraries.jpa
testCompile project( ':hibernate-core' )
testCompile libraries.slf4j_api
testCompile libraries.slf4j_log4j
}
def pomName() {
return 'Hibernate JPA 2 Metamodel Generator'
}
def pomDescription() {
return 'Annotation Processor to generate JPA 2 static metamodel classes'
}
versionInjection {
into( 'org.hibernate.jpamodelgen.Version', 'getVersionString' )
}
sourceSets.main {
ext.jaxbTargetDir = file( "${buildDir}/generated-sources" )
java.srcDir jaxbTargetDir
}
sourceSets.main {
ext.xsdDir = file( "${projectDir}/src/main/xsd" )
resources.srcDir xsdDir
}
jar {
manifest {
attributes 'Implementation-Title' : '${project.name}',
'Implementation-Version' : '${project.version}'
}
}
task jaxb {
// output directory
ext.jaxbTargetDir = file( "${buildDir}/generated-sources" )
// input schema
ext.ormXsd = file( 'src/main/xsd/orm_2_0.xsd')
ext.persistenceXsd = file( 'src/main/xsd/persistence_2_0.xsd')
// configure Gradle up-to-date checking
inputs.files( [ormXsd, persistenceXsd] )
outputs.dir( jaxbTargetDir )
// perform actions
doLast {
jaxbTargetDir.mkdirs()
ant.taskdef(name: 'xjc', classname: 'org.jvnet.jaxb2_commons.xjc.XJC2Task', classpath: configurations.jaxb.asPath)
ant.jaxbTargetDir = jaxbTargetDir
ant.xjc(
destdir: '${jaxbTargetDir}',
package: 'org.hibernate.jpamodelgen.xml.jaxb',
extension: 'true'
) {
schema (dir:"src/main/xsd", includes:"*.xsd")
}
}
}
compileJava.dependsOn jaxb
checkstyleMain.exclude '**/jaxb/**'