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

75 lines
2.0 KiB
Groovy

/*
* 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>.
*/
plugins {
id 'org.hibernate.build.xjc-jakarta'
}
description = 'Annotation Processor to generate JPA 2 static metamodel classes'
apply from: rootProject.file( 'gradle/published-java-module.gradle' )
apply plugin: 'version-injection'
ext {
xjcTargetDir = file( "${buildDir}/generated/sources/xjc/main" )
xsdDir = file( "${projectDir}/src/main/xsd" )
}
dependencies {
implementation libraries.jaxb_api
implementation libraries.jakarta_jaxb_runtime
xjc libraries.jakarta_jaxb_xjc
xjc libraries.jakarta_jaxb_runtime
xjc rootProject.fileTree(dir: 'patched-libs/jaxb2-basics', include: '*.jar')
testImplementation project( ':hibernate-core' )
testImplementation libraries.junit
// testImplementation libraries.jakarta_jpa
testImplementation libraries.jakarta_validation
}
sourceSets.main {
java.srcDir xjcTargetDir
resources.srcDir xsdDir
}
compileTestJava {
options.compilerArgs += [
"-proc:none"
]
}
task jaxb {
// configure Gradle up-to-date checking
inputs.dir( xsdDir ).withPropertyName("xsdDir" ).withPathSensitivity( PathSensitivity.RELATIVE )
outputs.dir( xjcTargetDir )
outputs.cacheIf { true }
// perform actions
doLast {
xjcTargetDir.mkdirs()
ant.taskdef(name: 'xjc', classname: 'org.jvnet.jaxb2_commons.xjc.XJC2Task', classpath: configurations.xjc.asPath)
ant.xjc(
destdir: ( xjcTargetDir as File ).absolutePath,
package: 'org.hibernate.jpamodelgen.xml.jaxb',
extension: 'true'
) {
project.ant.arg line: '-no-header'
project.ant.arg line: '-npa'
schema( dir: xsdDir.path, includes: "*.xsd" )
}
}
}
tasks.compileJava.dependsOn jaxb
checkstyleMain.exclude '**/jaxb/**'