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

225 lines
6.2 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" )
}
sourceSets {
quarkusOrmPanache {
java {
srcDirs = ['src/quarkusOrmPanache/java']
}
resources {
srcDirs sourceSets.main.resources
}
compileClasspath += sourceSets.main.output + sourceSets.test.output
runtimeClasspath += sourceSets.main.output + sourceSets.test.output
}
quarkusHrPanache {
java {
srcDirs = ['src/quarkusHrPanache/java']
}
resources {
srcDirs sourceSets.main.resources
}
compileClasspath += sourceSets.main.output + sourceSets.test.output
runtimeClasspath += sourceSets.main.output + sourceSets.test.output
}
jakartaData {
java {
srcDirs = ['src/jakartaData/java']
}
resources {
srcDirs sourceSets.main.resources
}
compileClasspath += sourceSets.main.output + sourceSets.test.output
runtimeClasspath += sourceSets.main.output + sourceSets.test.output
}
2024-02-28 09:29:25 -05:00
}
dependencies {
// api - ewww... but Maven needs them this way
api project( ':hibernate-core' )
api libs.hcann
api libs.jandex
api jakartaLibs.jaxbApi
api jakartaLibs.jaxb
api jakartaLibs.validation
api jakartaLibs.annotation
api libs.antlrRuntime
api libs.byteBuddy
api libs.logging
xjc jakartaLibs.xjc
xjc jakartaLibs.jaxb
xjc rootProject.fileTree(dir: 'patched-libs/jaxb2-basics', include: '*.jar')
2024-02-22 07:31:14 -05:00
quarkusOrmPanacheImplementation "io.quarkus:quarkus-hibernate-orm-panache:3.6.2"
quarkusHrPanacheImplementation "io.quarkus:quarkus-hibernate-reactive-panache:3.6.2"
jakartaDataImplementation "jakarta.data:jakarta.data-api:1.0.0-SNAPSHOT"
jakartaDataImplementation "org.hibernate.reactive:hibernate-reactive-core:2.2.2.Final"
jakartaDataImplementation "io.quarkus:quarkus-hibernate-orm-panache:3.6.2"
}
// The source set gets a custom configuration which extends the normal test implementation config
configurations {
quarkusOrmPanacheImplementation.extendsFrom(testImplementation)
quarkusOrmPanacheRuntimeOnly.extendsFrom(testRuntimeOnly)
quarkusOrmPanacheCompileOnly.extendsFrom(testCompileOnly)
quarkusHrPanacheImplementation.extendsFrom(testImplementation)
quarkusHrPanacheRuntimeOnly.extendsFrom(testRuntimeOnly)
quarkusHrPanacheCompileOnly.extendsFrom(testCompileOnly)
jakartaDataImplementation.extendsFrom(testImplementation)
jakartaDataRuntimeOnly.extendsFrom(testRuntimeOnly)
jakartaDataCompileOnly.extendsFrom(testCompileOnly)
2024-02-28 09:29:25 -05:00
}
def quarkusOrmPanacheTestTask = tasks.register( 'quarkusOrmPanacheTest', Test ) {
description = 'Runs the Quarkus ORM Panache tests.'
group = 'verification'
testClassesDirs = sourceSets.quarkusOrmPanache.output.classesDirs
classpath = sourceSets.quarkusOrmPanache.runtimeClasspath
2024-02-28 09:29:25 -05:00
shouldRunAfter test
}
def quarkusHrPanacheTestTask = tasks.register( 'quarkusHrPanacheTest', Test ) {
description = 'Runs the Quarkus HR Panache tests.'
group = 'verification'
testClassesDirs = sourceSets.quarkusHrPanache.output.classesDirs
classpath = sourceSets.quarkusHrPanache.runtimeClasspath
2024-02-28 09:29:25 -05:00
shouldRunAfter test
}
def jakartaDataTestTask = tasks.register( 'jakartaDataTest', Test ) {
description = 'Runs the Jakarta Data tests.'
group = 'verification'
testClassesDirs = sourceSets.jakartaData.output.classesDirs
classpath = sourceSets.jakartaData.runtimeClasspath
shouldRunAfter test
}
2024-02-28 09:29:25 -05:00
check.dependsOn quarkusHrPanacheTestTask
check.dependsOn quarkusOrmPanacheTestTask
test.dependsOn quarkusHrPanacheTestTask
test.dependsOn quarkusOrmPanacheTestTask
2024-02-28 09:29:25 -05:00
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
def testCompilerConfig = {
javaCompiler = javaToolchains.compilerFor {
languageVersion = jdkVersions.test.compile
}
sourceCompatibility = 17
targetCompatibility = 17
}
compileTestJava {
configure testCompilerConfig
}
compileQuarkusOrmPanacheJava {
configure testCompilerConfig
}
compileQuarkusHrPanacheJava {
configure testCompilerConfig
}
compileJakartaDataJava {
configure testCompilerConfig
}
def testLauncherConfig = {
javaLauncher = javaToolchains.launcherFor {
languageVersion = jdkVersions.test.launcher
}
}
test {
configure testLauncherConfig
}
quarkusOrmPanacheTest {
configure testLauncherConfig
}
quarkusHrPanacheTest {
configure testLauncherConfig
}
jakartaDataTest {
configure testLauncherConfig
}
}
else {
sourceSets {
test {
java {
exclude '**/records/*.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.processor.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/**'