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

109 lines
2.8 KiB
Groovy
Raw Normal View History

/*
* 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 = 'Hibernate compile-time tooling'
apply from: rootProject.file( 'gradle/published-java-module.gradle' )
apply plugin: 'version-injection'
2013-11-24 16:16:12 -05:00
ext {
xjcTargetDir = file( "${buildDir}/generated/sources/xjc/main" )
2013-11-24 16:16:12 -05:00
xsdDir = file( "${projectDir}/src/main/xsd" )
}
dependencies {
// api - ewww... but Maven needs them this way
api project( ':hibernate-core' )
api jakartaLibs.jaxbApi
api jakartaLibs.jaxb
api jakartaLibs.validation
api jakartaLibs.annotation
api libs.antlrRuntime
api libs.byteBuddy
xjc jakartaLibs.xjc
xjc jakartaLibs.jaxb
xjc rootProject.fileTree(dir: 'patched-libs/jaxb2-basics', include: '*.jar')
}
sourceSets.main {
java.srcDir xjcTargetDir
2013-11-24 16:16:12 -05:00
resources.srcDir xsdDir
}
2013-11-22 20:46:05 -05:00
compileTestJava {
options.compilerArgs += [
"-proc:none",
"-AsuppressJakartaDataMetamodel=true"
2013-11-22 20:46:05 -05:00
]
}
// Tests with records
2023-08-07 21:05:47 -04:00
if ( jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit ) {
// We need to configure the source and target version to 17
//compileTestJava17Java {
compileTestJava {
javaCompiler = javaToolchains.compilerFor {
2023-08-15 13:35:08 -04:00
languageVersion = jdkVersions.test.compile
}
sourceCompatibility = 17
targetCompatibility = 17
}
test {
javaLauncher = javaToolchains.launcherFor {
2023-08-15 13:35:08 -04:00
languageVersion = jdkVersions.test.launcher
}
}
}
else {
sourceSets {
test {
java {
exclude '**/records/*.java'
exclude '**/data/*.java'
}
}
}
}
task jaxb {
// configure Gradle up-to-date checking
2021-07-29 14:02:52 -04:00
inputs.dir( xsdDir ).withPropertyName("xsdDir" ).withPathSensitivity( PathSensitivity.RELATIVE )
outputs.dir( xjcTargetDir )
2021-07-29 14:02:52 -04:00
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'
) {
2021-07-26 14:51:22 -04:00
project.ant.arg line: '-no-header'
project.ant.arg line: '-npa'
schema( dir: xsdDir.path, includes: "*.xsd" )
}
}
}
tasks.sourcesJar.dependsOn jaxb
tasks.sourcesJar.dependsOn ':hibernate-core:generateHqlParser'
tasks.sourcesJar.dependsOn ':hibernate-core:generateSqlScriptParser'
tasks.compileJava.dependsOn jaxb
checkstyleMain.exclude '**/jaxb/**'