HHH-6194 - Better jaxb task to leverage Gradle up-to-date checking

This commit is contained in:
Steve Ebersole 2011-05-04 15:49:57 -05:00
parent 3090fe9c1d
commit 7a5f0b4836
1 changed files with 41 additions and 12 deletions

View File

@ -47,22 +47,51 @@ ideaModule {
sourceDirs.add( file( '$buildDir/generated-src/antlr/main' ) )
}
task jaxb << {
task jaxb {
// output directory
jaxbTargetDir = file( "${buildDir}/generated-src/jaxb/main" )
jaxbTargetDir.mkdirs()
ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath)
ant.jaxbTargetDir = jaxbTargetDir
// input schemas
cfgXsd = file( 'src/main/resources/org/hibernate/hibernate-configuration-4.0.xsd')
hbmXsd = file( 'src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd' )
ormXsd = file( 'src/main/resources/org/hibernate/ejb/orm_2_0.xsd' )
ant.xjc(destdir: '${jaxbTargetDir}', package: 'org.hibernate.metamodel.source.hbm.xml.config', binding: 'src/main/xjb/hbm-configuration-bindings.xjb') {
schema(dir: 'src/main/resources/org/hibernate', includes: 'hibernate-configuration-4.0.xsd')
}
ant.xjc(destdir: '${jaxbTargetDir}', package: 'org.hibernate.metamodel.source.hbm.xml.mapping', binding: 'src/main/xjb/hbm-mapping-bindings.xjb') {
schema(dir: 'src/main/resources/org/hibernate', includes: 'hibernate-mapping-4.0.xsd')
}
ant.xjc(destdir: '${jaxbTargetDir}', package: 'org.hibernate.metamodel.source.annotation.xml', binding: 'src/main/xjb/orm-bindings.xjb') {
schema(dir: 'src/main/resources/org/hibernate/ejb', includes: 'orm_2_0.xsd')
// configure Gradle up-to-date checking
inputs.files( [cfgXsd, hbmXsd, ormXsd] )
outputs.dir( jaxbTargetDir )
// perform actions
doLast {
jaxbTargetDir.mkdirs()
ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath)
ant.jaxbTargetDir = jaxbTargetDir
// hibernate-configuration
ant.xjc(
destdir: '${jaxbTargetDir}',
package: 'org.hibernate.metamodel.source.hbm.xml.config',
binding: 'src/main/xjb/hbm-configuration-bindings.xjb',
schema: cfgXsd.path
)
// hibernate-mapping
ant.xjc(
destdir: '${jaxbTargetDir}',
package: 'org.hibernate.metamodel.source.hbm.xml.mapping',
binding: 'src/main/xjb/hbm-mapping-bindings.xjb',
schema: hbmXsd.path
)
// orm.xml (jpa)
ant.xjc(
destdir: '${jaxbTargetDir}',
package: 'org.hibernate.metamodel.source.annotation.xml',
binding: 'src/main/xjb/orm-bindings.xjb',
schema: ormXsd.path
)
}
}
compileJava.dependsOn jaxb