diff --git a/build.gradle b/build.gradle
index 51b795641a..c9082a2b55 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,10 +26,10 @@ buildscript {
plugins {
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'nu.studer.credentials' version '2.1'
- id 'org.hibernate.build.plugin' version '1.0.0-SNAPSHOT' apply false
+ id 'org.hibernate.orm.database-service' version '1.0.0-SNAPSHOT' apply false
id 'idea'
- id 'org.jetbrains.gradle.plugin.idea-ext' version '0.5'
+ id 'org.jetbrains.gradle.plugin.idea-ext' version '1.0'
id 'eclipse'
id 'org.hibernate.build.xjc' version '2.0.1' apply false
@@ -49,6 +49,7 @@ allprojects {
}
apply from: rootProject.file( 'gradle/base-information.gradle' )
+ apply plugin: 'org.hibernate.orm.database-service'
apply plugin: 'idea'
apply plugin: 'eclipse'
diff --git a/database-service-plugin/build.gradle b/database-service-plugin/build.gradle
index 31ead351bf..0ade488d44 100644
--- a/database-service-plugin/build.gradle
+++ b/database-service-plugin/build.gradle
@@ -6,7 +6,6 @@
*/
repositories {
mavenCentral()
- jcenter()
}
apply plugin: 'java-gradle-plugin'
@@ -16,7 +15,7 @@ version = '1.0.0-SNAPSHOT'
buildDir = "target"
dependencies {
- compile gradleApi()
+ implementation gradleApi()
}
tasks.compileJava {
@@ -27,9 +26,9 @@ tasks.compileJava {
gradlePlugin {
plugins {
- customPlugin {
- id = 'org.hibernate.build.plugin'
- implementationClass = 'org.hibernate.build.HibernateBuildPlugin'
+ databaseServicePlugin {
+ id = 'org.hibernate.orm.database-service'
+ implementationClass = 'org.hibernate.orm.db.DatabaseServicePlugin'
}
}
}
diff --git a/database-service-plugin/src/main/java/org/hibernate/build/HibernateBuildPlugin.java b/database-service-plugin/src/main/java/org/hibernate/build/HibernateBuildPlugin.java
deleted file mode 100644
index f74928e000..0000000000
--- a/database-service-plugin/src/main/java/org/hibernate/build/HibernateBuildPlugin.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 .
- */
-package org.hibernate.build;
-
-import java.util.Set;
-
-import org.gradle.api.Plugin;
-import org.gradle.api.Project;
-import org.gradle.api.Task;
-import org.gradle.api.provider.Provider;
-
-
-/**
- * @author Christian Beikov
- */
-public class HibernateBuildPlugin implements Plugin {
-
- @Override
- public void apply(Project project) {
- Provider provider = project.getGradle().getSharedServices().registerIfAbsent(
- "db",
- DatabaseService.class,
- spec -> {
- spec.getMaxParallelUsages().set( 1 );
- }
- );
- Set tasks = project.getTasksByName( "test", false );
- for ( Task task : tasks ) {
- task.usesService( provider );
- }
- }
-}
diff --git a/database-service-plugin/src/main/java/org/hibernate/build/DatabaseService.java b/database-service-plugin/src/main/java/org/hibernate/orm/db/DatabaseService.java
similarity index 62%
rename from database-service-plugin/src/main/java/org/hibernate/build/DatabaseService.java
rename to database-service-plugin/src/main/java/org/hibernate/orm/db/DatabaseService.java
index 63e299a515..c7f6a8587f 100644
--- a/database-service-plugin/src/main/java/org/hibernate/build/DatabaseService.java
+++ b/database-service-plugin/src/main/java/org/hibernate/orm/db/DatabaseService.java
@@ -1,13 +1,14 @@
/*
* 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 .
+ * 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
*/
-package org.hibernate.build;
+package org.hibernate.orm.db;
import org.gradle.api.services.BuildService;
import org.gradle.api.services.BuildServiceParameters;
public abstract class DatabaseService implements BuildService {
+ public static final String REGISTRATION_NAME = "databaseService";
}
diff --git a/database-service-plugin/src/main/java/org/hibernate/orm/db/DatabaseServicePlugin.java b/database-service-plugin/src/main/java/org/hibernate/orm/db/DatabaseServicePlugin.java
new file mode 100644
index 0000000000..29ae0d2905
--- /dev/null
+++ b/database-service-plugin/src/main/java/org/hibernate/orm/db/DatabaseServicePlugin.java
@@ -0,0 +1,37 @@
+/*
+ * 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
+ */
+package org.hibernate.orm.db;
+
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+import org.gradle.api.provider.Provider;
+import org.gradle.api.services.BuildServiceRegistry;
+import org.gradle.api.tasks.testing.Test;
+
+import static org.hibernate.orm.db.DatabaseService.REGISTRATION_NAME;
+
+/**
+ * @author Steve Ebersole
+ */
+public class DatabaseServicePlugin implements Plugin {
+ @Override
+ @SuppressWarnings("UnstableApiUsage")
+ public void apply(Project project) {
+ // register the service used to restrict parallel execution
+ // of tests - used to avoid database schema/catalog collisions
+ final BuildServiceRegistry sharedServices = project.getGradle().getSharedServices();
+ final Provider databaseServiceProvider = sharedServices.registerIfAbsent(
+ REGISTRATION_NAME,
+ DatabaseService.class,
+ spec -> spec.getMaxParallelUsages().set( 1 )
+ );
+
+ project.getTasks().withType( Test.class ).forEach(
+ test -> test.usesService( databaseServiceProvider )
+ );
+ }
+}
diff --git a/database-service-plugin/src/main/java/org/hibernate/orm/jakarta/JakartaDirectoryTransformation.java b/database-service-plugin/src/main/java/org/hibernate/orm/jakarta/JakartaDirectoryTransformation.java
new file mode 100644
index 0000000000..5b8b681e7c
--- /dev/null
+++ b/database-service-plugin/src/main/java/org/hibernate/orm/jakarta/JakartaDirectoryTransformation.java
@@ -0,0 +1,76 @@
+/*
+ * 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
+ */
+package org.hibernate.orm.jakarta;
+
+import java.io.File;
+import javax.inject.Inject;
+
+import org.gradle.api.DefaultTask;
+import org.gradle.api.file.DirectoryProperty;
+import org.gradle.api.file.RegularFileProperty;
+import org.gradle.api.model.ObjectFactory;
+import org.gradle.api.tasks.InputDirectory;
+import org.gradle.api.tasks.OutputDirectory;
+import org.gradle.api.tasks.TaskAction;
+
+/**
+ * @author Steve Ebersole
+ */
+public abstract class JakartaDirectoryTransformation extends DefaultTask {
+ private final DirectoryProperty sourceDirectory;
+ private final DirectoryProperty targetDirectory;
+
+ @Inject
+ public JakartaDirectoryTransformation(ObjectFactory objectFactory) {
+ sourceDirectory = objectFactory.directoryProperty();
+ targetDirectory = objectFactory.directoryProperty();
+ }
+
+ @InputDirectory
+ public DirectoryProperty getSourceDirectory() {
+ return sourceDirectory;
+ }
+
+ @OutputDirectory
+ public DirectoryProperty getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ @TaskAction
+ void transform() {
+ final File sourceDirAsFile = sourceDirectory.get().getAsFile();
+ final File targetDirAsFile = targetDirectory.get().getAsFile();
+
+ // If the target directory already exists, the transformer tool will
+ // skip the transformation - even if the directory is empty.
+ // Gradle is nice enough to make sure that directory exists, but
+ // unfortunately that "confuses" the transformer tool.
+ //
+ // For now, delete the dir before executing the transformer.
+ //
+ // NOTE : Gradle has already done its up-to-date checks and our task
+ // is actually executing at this point, so deleting the directory will
+ // have no effect on the incremental build
+
+ targetDirAsFile.delete();
+
+ getProject().javaexec(
+ (javaExecSpec) -> {
+ javaExecSpec.classpath( getProject().getConfigurations().getByName( "jakartaeeTransformTool" ) );
+ javaExecSpec.setMain( "org.eclipse.transformer.jakarta.JakartaTransformer" );
+ javaExecSpec.args(
+ sourceDirAsFile.getAbsolutePath(),
+ targetDirAsFile.getAbsolutePath(),
+ "-q",
+ "-tr", getProject().getRootProject().file( "rules/jakarta-renames.properties" ).getAbsolutePath(),
+ "-tv", getProject().getRootProject().file( "rules/jakarta-versions.properties" ).getAbsolutePath(),
+ "-td", getProject().getRootProject().file( "rules/jakarta-direct.properties" ).getAbsolutePath()
+ );
+ }
+ );
+ }
+}
diff --git a/database-service-plugin/src/main/java/org/hibernate/orm/jakarta/JakartaJarTransformation.java b/database-service-plugin/src/main/java/org/hibernate/orm/jakarta/JakartaJarTransformation.java
new file mode 100644
index 0000000000..7982b72e5f
--- /dev/null
+++ b/database-service-plugin/src/main/java/org/hibernate/orm/jakarta/JakartaJarTransformation.java
@@ -0,0 +1,58 @@
+/*
+ * 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
+ */
+package org.hibernate.orm.jakarta;
+
+import javax.inject.Inject;
+
+import org.gradle.api.DefaultTask;
+import org.gradle.api.file.RegularFileProperty;
+import org.gradle.api.model.ObjectFactory;
+import org.gradle.api.tasks.InputFile;
+import org.gradle.api.tasks.OutputFile;
+import org.gradle.api.tasks.TaskAction;
+
+/**
+ * @author Steve Ebersole
+ */
+public abstract class JakartaJarTransformation extends DefaultTask {
+ private final RegularFileProperty sourceJar;
+ private final RegularFileProperty targetJar;
+
+ @Inject
+ public JakartaJarTransformation(ObjectFactory objectFactory) {
+ sourceJar = objectFactory.fileProperty();
+ targetJar = objectFactory.fileProperty();
+ }
+
+ @InputFile
+ public RegularFileProperty getSourceJar() {
+ return sourceJar;
+ }
+
+ @OutputFile
+ public RegularFileProperty getTargetJar() {
+ return targetJar;
+ }
+
+ @TaskAction
+ void transform() {
+ getProject().javaexec(
+ (javaExecSpec) -> {
+ javaExecSpec.classpath( getProject().getConfigurations().getByName( "jakartaeeTransformTool" ) );
+ javaExecSpec.setMain( "org.eclipse.transformer.jakarta.JakartaTransformer" );
+ javaExecSpec.args(
+ sourceJar.get().getAsFile().getAbsolutePath(),
+ targetJar.get().getAsFile().getAbsolutePath(),
+ "-q",
+ "-tr", getProject().getRootProject().file( "rules/jakarta-renames.properties" ).getAbsolutePath(),
+ "-tv", getProject().getRootProject().file( "rules/jakarta-versions.properties" ).getAbsolutePath(),
+ "-td", getProject().getRootProject().file( "rules/jakarta-direct.properties" ).getAbsolutePath()
+ );
+ }
+ );
+ }
+}
diff --git a/documentation/documentation.gradle b/documentation/documentation.gradle
index 3cf153316d..5ead573e59 100644
--- a/documentation/documentation.gradle
+++ b/documentation/documentation.gradle
@@ -176,7 +176,7 @@ task aggregateJavadocs(type: Javadoc) {
}
}
-asciidoctor {
+tasks.asciidoctor {
// we do not want it creating its "default task"
enabled = false
}
diff --git a/gradle/jakarta-java-module.gradle b/gradle/jakarta-java-module.gradle
index 8c53d1ff74..1e4fb5ad88 100644
--- a/gradle/jakarta-java-module.gradle
+++ b/gradle/jakarta-java-module.gradle
@@ -8,72 +8,44 @@
apply from: rootProject.file( 'gradle/java-module.gradle' )
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
+configurations {
+ jakartaeeTransformTool {
+ description = 'JakartaTransformer tool dependencies'
+ }
+ tests {
+ description = 'Configuration for the produced test jar'
+ }
+}
+
+dependencies {
+ jakartaeeTransformTool 'org.eclipse.transformer:org.eclipse.transformer:0.2.0'
+ jakartaeeTransformTool 'org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0'
+}
+
+tasks.withType( Test ) { test ->
+ test.usesService( project.gradle.sharedServices.registrations.getByName( 'databaseService' ).service )
+}
+
publishing {
publications {
publishedArtifacts {
from components.java
}
-
- relocationArtifacts( MavenPublication ) {
- pom {
- name = project.name + ' - relocation'
- groupId = 'org.hibernate'
- artifactId = project.name
- version = project.version
-
- description = project.description
- url = 'https://hibernate.org/orm'
-
- organization {
- name = 'Hibernate.org'
- url = 'https://hibernate.org'
- }
-
- licenses {
- license {
- name = 'GNU Library General Public License v2.1 or later'
- url = 'https://www.opensource.org/licenses/LGPL-2.1'
- comments = 'See discussion at https://hibernate.org/community/license/ for more details.'
- distribution = 'repo'
- }
- }
-
- scm {
- url = 'https://github.com/hibernate/hibernate-orm'
- connection = 'scm:git:https://github.com/hibernate/hibernate-orm.git'
- developerConnection = 'scm:git:git@github.com:hibernate/hibernate-orm.git'
- }
-
- developers {
- developer {
- id = 'hibernate-team'
- name = 'The Hibernate Development Team'
- organization = 'Hibernate.org'
- organizationUrl = 'https://hibernate.org'
- }
- }
-
- issueManagement {
- system = 'jira'
- url = 'https://hibernate.atlassian.net/browse/HHH'
- }
-
- distributionManagement {
- relocation {
- groupId = 'org.hibernate.orm'
- artifactId = project.name
- version = project.version
- }
- }
- }
- }
}
}
+java {
+ withJavadocJar()
+ withSourcesJar()
+}
+
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Release / publishing tasks
task ciBuild( dependsOn: [test, publish] )
task release(dependsOn: [test, publishToSonatype])
-publishToSonatype.mustRunAfter test
\ No newline at end of file
+publishToSonatype.mustRunAfter test
+
+
diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle
index e777dbad24..d0bf5d508c 100644
--- a/gradle/java-module.gradle
+++ b/gradle/java-module.gradle
@@ -14,7 +14,7 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'de.thetaphi:forbiddenapis:3.0.1'
+ classpath 'de.thetaphi:forbiddenapis:3.1'
}
}
@@ -24,24 +24,14 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply from: rootProject.file( 'gradle/libraries.gradle' )
apply from: rootProject.file( 'gradle/databases.gradle' )
-apply plugin: 'java'
-apply plugin: 'org.hibernate.build.plugin'
apply plugin: 'java-library'
+apply plugin: 'org.hibernate.orm.database-service'
apply plugin: 'biz.aQute.bnd.builder'
apply plugin: 'checkstyle'
apply plugin: 'build-dashboard'
apply plugin: 'project-report'
-ext {
- forbiddenAPITargetJDKCompatibility = '11'
-}
-
-if ( !project.description ) {
- project.description = "The Hibernate ORM $project.name module"
-}
-
-
// Attempt to leverage JetBrain's Gradle extension to automatically define
// `copyResourcesToIntelliJOutFolder` as a "build trigger" on import.
@@ -211,10 +201,6 @@ else {
task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] )
-sourceSets.main {
- compileClasspath += configurations.provided
-}
-
convention.findPlugin( JavaPluginConvention.class ).sourceSets.each { sourceSet ->
JavaCompile javaCompileTask = project.tasks.findByName( sourceSet.compileJavaTaskName ) as JavaCompile
@@ -269,6 +255,8 @@ if ( gradle.ext.javaToolchainEnabled ) {
tasks.withType( Test.class ).each { test ->
test.useJUnitPlatform()
+ test.usesService( project.gradle.sharedServices.registrations.getByName( 'databaseService' ).service )
+
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
// Byteman needs this property to be set, https://developer.jboss.org/thread/274997
test.jvmArgs += ["-Djdk.attach.allowAttachSelf=true"]
@@ -435,64 +423,14 @@ task sourcesJar(type: Jar) {
apply from: rootProject.file( 'gradle/javadoc.gradle' )
-javadoc {
- doFirst {
- // ordering problems if we try to do this during config phase :(
- classpath += project.sourceSets.main.output.classesDirs + project.sourceSets.main.compileClasspath + project.configurations.provided
- }
-}
-
-task javadocJar(type: Jar) {
- from project.tasks.javadoc.outputs
- manifest {
- attributes(
- // Basic JAR manifest attributes
- 'Specification-Title': project.name,
- 'Specification-Version': project.version,
- 'Specification-Vendor': 'Hibernate.org',
- 'Implementation-Title': project.name,
- 'Implementation-Version': project.version,
- 'Implementation-Vendor': 'Hibernate.org',
- 'Implementation-Vendor-Id': 'org.hibernate',
- 'Implementation-Url': 'https://hibernate.org/orm',
-
- // Hibernate-specific JAR manifest attributes
- 'Hibernate-VersionFamily': project.ormVersion.family,
- 'Hibernate-JpaVersion': project.jpaVersion.name
- )
- }
- archiveClassifier.set( 'javadoc' )
-}
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// IDE
-//idea {
-// module {
-// jdkName = project.sourceCompatibility
-//
-// excludeDirs = [file( ".gradle" )]
-// excludeDirs += file( "$buildDir/classes" )
-// excludeDirs += file( "$buildDir/bundles" )
-// excludeDirs += file( "$buildDir/packages" )
-// excludeDirs += file( "$buildDir/dependency-cache" )
-// excludeDirs += file( "$buildDir/libs" )
-// excludeDirs += file( "$buildDir/reports" )
-// excludeDirs += file( "$buildDir/test-results" )
-// excludeDirs += file( "$buildDir/tmp" )
-// excludeDirs += file( "$buildDir/matrix" )
-// excludeDirs += file( "$buildDir/resources" )
-//
-// downloadSources = true
-// scopes.PROVIDED.plus += [configurations.provided]
-// }
-//}
-//
/*
- The latest versions of IntelliJ copy and use the test resources into out/test/resources
- this occurs before the placeholder in the test config file are substituted
- with the testing values.
+ The latest versions of IntelliJ copy the test resources into out/test/resources and
+ use those for its test classpath. Unfortunately, this occurs before the placeholder
+ in the test config file are substituted with the testing values.
This behaviour prevents the execution of the hibernate tests from inside the IDE.
@@ -507,23 +445,8 @@ task copyResourcesToIntelliJOutFolder(type: Task, dependsOn: project.tasks.proce
}
}
}
-//
-//
-//
-//eclipse {
-// jdt {
-// sourceCompatibility = project.sourceCompatibility
-// targetCompatibility = project.targetCompatibility
-// }
-// classpath {
-// plusConfigurations.add( configurations.provided )
-// }
-//}
-//
-//// eclipseClasspath will not add sources to classpath unless the dirs actually exist.
-//// TODO: Eclipse's annotation processor handling is also fairly stupid (and completely lacks in the
-//// Gradle plugin). For now, just compile first in order to get the logging classes.
-//eclipseClasspath.dependsOn compile
+
+
/*
Use this task to set the current DB in a given module.
@@ -563,21 +486,11 @@ checkstyleMain.exclude '**/org/hibernate/cfg/*'
task forbiddenApisSystemOut(type: CheckForbiddenApis, dependsOn: compileJava) {
- classesDirs = project.sourceSets.main.output.classesDirs
- classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
- targetCompatibility = project.forbiddenAPITargetJDKCompatibility
bundledSignatures += 'jdk-system-out'
suppressAnnotations += ['org.hibernate.internal.build.AllowSysOut', 'org.hibernate.internal.build.AllowPrintStacktrace']
-
- // This slows down the checks a little, but is necessary to avoid the gradle deamon holding on
- // to class definitions loaded previously - even possibly in a previous build.
- disableClassloadingCache = true
}
task forbiddenApisUnsafe(type: CheckForbiddenApis, dependsOn: compileJava) {
- classesDirs = project.sourceSets.main.output.classesDirs
- classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
- targetCompatibility = project.forbiddenAPITargetJDKCompatibility
bundledSignatures += "jdk-unsafe-${gradle.ext.baselineJavaVersion}".toString()
// unfortunately we currently have many uses of default Locale implicitly (~370) which need to be fixed
@@ -585,24 +498,23 @@ task forbiddenApisUnsafe(type: CheckForbiddenApis, dependsOn: compileJava) {
//
// No idea how findbugs was missing these b4
ignoreFailures = true
-
- // This slows down the checks a little, but is necessary to avoid the gradle deamon holding on
- // to class definitions loaded previously - even possibly in a previous build.
- disableClassloadingCache = true
}
task forbiddenApisNonPortable(type: CheckForbiddenApis, dependsOn: compileJava) {
- classesDirs = project.sourceSets.main.output.classesDirs
- classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
- targetCompatibility = project.forbiddenAPITargetJDKCompatibility
bundledSignatures += 'jdk-non-portable'
-
- // This slows down the checks a little, but is necessary to avoid the gradle deamon holding on
- // to class definitions loaded previously - even possibly in a previous build.
- disableClassloadingCache = true
}
task forbiddenApis
-project.tasks.withType( CheckForbiddenApis ).each { task -> forbiddenApis.finalizedBy task }
+project.tasks.withType( CheckForbiddenApis ).each { task ->
+ task.outputs.dirs project.sourceSets.main.output.classesDirs
+ task.classesDirs = project.sourceSets.main.output.classesDirs
+ task.classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
+ task.targetCompatibility = project.forbiddenAPITargetJDKCompatibility
+ // This slows down the checks a little, but is necessary to avoid the gradle deamon holding on
+ // to class definitions loaded previously - even possibly in a previous build.
+ task.disableClassloadingCache = true
-project.tasks.check.finalizedBy forbiddenApis
+ tasks.forbiddenApis.finalizedBy task
+}
+
+project.tasks.check.finalizedBy tasks.forbiddenApis
diff --git a/gradle/javadoc.gradle b/gradle/javadoc.gradle
index 2eb8e50948..d5b37d59a0 100644
--- a/gradle/javadoc.gradle
+++ b/gradle/javadoc.gradle
@@ -57,4 +57,26 @@ javadoc {
'implNote:a:"Implementation Note:"'
)
}
+}
+
+task javadocJar(type: Jar) {
+ from project.tasks.javadoc.outputs
+ manifest {
+ attributes(
+ // Basic JAR manifest attributes
+ 'Specification-Title': project.name,
+ 'Specification-Version': project.version,
+ 'Specification-Vendor': 'Hibernate.org',
+ 'Implementation-Title': project.name,
+ 'Implementation-Version': project.version,
+ 'Implementation-Vendor': 'Hibernate.org',
+ 'Implementation-Vendor-Id': 'org.hibernate',
+ 'Implementation-Url': 'https://hibernate.org/orm',
+
+ // Hibernate-specific JAR manifest attributes
+ 'Hibernate-VersionFamily': project.ormVersion.family,
+ 'Hibernate-JpaVersion': project.jpaVersion.name
+ )
+ }
+ archiveClassifier.set( 'javadoc' )
}
\ No newline at end of file
diff --git a/hibernate-core-jakarta/hibernate-core-jakarta.gradle b/hibernate-core-jakarta/hibernate-core-jakarta.gradle
index 04ea807437..427b45a2e4 100644
--- a/hibernate-core-jakarta/hibernate-core-jakarta.gradle
+++ b/hibernate-core-jakarta/hibernate-core-jakarta.gradle
@@ -1,22 +1,19 @@
+import javax.inject.Inject
+
/*
* 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 .
*/
-
-import org.apache.tools.ant.filters.ReplaceTokens
+import org.hibernate.orm.jakarta.JakartaDirectoryTransformation
+import org.hibernate.orm.jakarta.JakartaJarTransformation
description = 'Hibernate O/RM implementation of the Jakarta Persistence specification'
apply from: rootProject.file( 'gradle/jakarta-java-module.gradle' )
-configurations {
- tests {
- description = 'Configuration for the produced test jar'
- }
- jakartaeeTransformJars
-}
+evaluationDependsOn( ':hibernate-core' )
dependencies {
api libraries.jakarta_jpa
@@ -40,13 +37,6 @@ dependencies {
api libraries.jakarta_jaxb_api
api libraries.jakarta_jaxb_runtime
- jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1',
- 'commons-cli:commons-cli:1.4',
- 'org.slf4j:slf4j-simple:1.7.30',
- 'org.slf4j:slf4j-api:1.7.26',
- 'org.eclipse.transformer:org.eclipse.transformer:0.2.0',
- 'org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0'
-
testImplementation project(':hibernate-testing-jakarta')
testImplementation fileTree(dir: 'libs', include: '*.jar')
@@ -91,92 +81,139 @@ dependencies {
testImplementation libraries.jboss_annotation_spec_jar
}
-jar {
- mustRunAfter project(':hibernate-core').tasks.jar
- mustRunAfter project(':hibernate-core').tasks.testJar
- dependsOn project(':hibernate-core').tasks.jar
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// main jar
+
+tasks.jar {
+ enabled false
+}
+
+task jakartafyJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-core').tasks.jar.archiveFile
+ targetJar = tasks.jar.archiveFile
+}
+
+tasks.jar.dependsOn project(':hibernate-core').tasks.jar
+tasks.jar.finalizedBy tasks.jakartafyJar
+tasks.jakartafyJar.dependsOn tasks.jar
+tasks.jakartafyJar.mustRunAfter tasks.jar
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// javadoc jar
+
+tasks.javadocJar {
+ enabled false
+}
+
+task jakartafyJavadocJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-core').tasks.javadocJar.archiveFile
+ targetJar = tasks.javadocJar.archiveFile
+}
+
+tasks.javadocJar.dependsOn project(':hibernate-core').tasks.javadocJar
+tasks.javadocJar.finalizedBy tasks.jakartafyJavadocJar
+tasks.jakartafyJavadocJar.dependsOn tasks.javadocJar
+tasks.jakartafyJavadocJar.mustRunAfter tasks.javadocJar
+
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// sources jar
+
+tasks.sourcesJar {
+ enabled false
+}
+
+task jakartafySourcesJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-core').tasks.sourcesJar.archiveFile
+ targetJar = tasks.javadocJar.archiveFile
+}
+
+tasks.sourcesJar.dependsOn project(':hibernate-core').tasks.sourcesJar
+tasks.sourcesJar.finalizedBy tasks.jakartafySourcesJar
+tasks.jakartafySourcesJar.dependsOn tasks.sourcesJar
+tasks.jakartafySourcesJar.mustRunAfter tasks.sourcesJar
+
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// testing
+
+project.ext {
+ testClassesUnpackTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/unpack/classes' )
+ testClassesTransformationTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/test/classes' )
+
+ templateUnpackTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/unpack/templates' )
+ templatesTransformationTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/test/templates' )
+}
+
+tasks.compileTestJava {
+ enabled false
dependsOn project(':hibernate-core').tasks.testJar
-
- def baseDir = project(':hibernate-core').buildDir
- def baseJars = fileTree(baseDir).matching {include 'libs/*.jar' }
-
- inputs.files(baseJars).skipWhenEmpty()
- outputs.dir project.buildDir
-
- doLast {
- new File(project.buildDir, "libs").mkdirs()
- fileTree(project.buildDir).matching { include 'libs/*.jar' }.each { delete it }
-
- baseJars.each { bundleJar ->
- def sourceJarPath = baseDir.path + '/libs/' + bundleJar.name
- println 'Initial bundle jar name [ ' + sourceJarPath + ' ]'
-
- def finalBundleJarName = project.buildDir.path + '/libs/' + bundleJar.name.replaceAll( 'hibernate-core', 'hibernate-core-jakarta' )
- println 'Default jakarta final bundle jar name [ ' + finalBundleJarName + ' ]'
-
- def transformerArgs = [
- sourceJarPath, finalBundleJarName,
- '-q', // quiet output
- '-tr', new File(getProjectDir().getParentFile(), 'rules/jakarta-renames.properties').path,
- '-tv', new File(getProjectDir().getParentFile(), 'rules/jakarta-versions.properties').path,
- '-td', new File(getProjectDir().getParentFile(), 'rules/jakarta-direct.properties').path,
- ]
-
- println 'Transformer options:'
- transformerArgs.each {
- println ' [ ' + it + ' ]'
- }
-
- javaexec {
- classpath configurations.jakartaeeTransformJars
- main = 'org.eclipse.transformer.jakarta.JakartaTransformer'
- args = transformerArgs
- }
- }
- }
}
-task unpackTestJar(type: Copy) {
- dependsOn jar
- fileTree(project.buildDir).matching { include 'libs/*-test.jar' }.each {
- def outputDir = file("${buildDir}/unpacked/" + it.name)
- from zipTree(it)
- into outputDir
- }
+task unpackTests(type: Copy) {
+ from zipTree( project( ':hibernate-core' ).tasks.testJar.archiveFile )
+ into project.testClassesUnpackTargetDirectory
+ exclude 'templates/**'
}
-task copyBundleResources (type: Copy) {
- dependsOn unpackTestJar
- File unpackedDir = new File(project.buildDir, "libs/hibernate-core-jakarta-${project.version}-test.jar")
- ext {
- bundlesTargetDir = file( "${buildDir}/bundles" )
- bundleTokens = dbBundle[db]
- ext.bundleTokens['buildDirName'] = buildDir.absolutePath
- }
- from file("${buildDir}/unpacked/${unpackedDir.name}/templates")
- into ext.bundlesTargetDir
+task jakartafyTests(type: JakartaDirectoryTransformation) {
+ sourceDirectory = project.testClassesUnpackTargetDirectory
+ targetDirectory = project.testClassesTransformationTargetDirectory
+}
+
+
+tasks.compileTestJava.finalizedBy tasks.jakartafyTests
+tasks.jakartafyTests.dependsOn tasks.unpackTests
+tasks.unpackTests.dependsOn project( ':hibernate-core' ).tasks.testJar
+
+tasks.processTestResources {
+ enabled false
+}
+
+task copyTestBundles(type: Copy) {
+ // `:hibernate-core:processTestResources` also triggers processing the
+ // packaging "bundle templates" into it's `${buildDir}/bundles` dir.
+ // we want to start with that form
+ dependsOn project( ':hibernate-core' ).tasks.processTestResources
+
+ inputs.dir project( ':hibernate-core' ).layout.buildDirectory.dir( 'bundles' )
+ outputs.dir project.templateUnpackTargetDirectory
+
+ from project( ':hibernate-core' ).layout.buildDirectory.dir( 'bundles' )
+ into project.templateUnpackTargetDirectory
+
// There are persistence.xml files referencing jar files through their absolute path so we
- // have to replace 'hibernate-core/hibernate-core' in the path with 'hibernate-core/hibernate-core-jakarta'
+ // have to replace 'hibernate-core' references in the path with 'hibernate-core-jakarta'
filter { line ->
line.replaceAll( 'hibernate-core/target', 'hibernate-core-jakarta/target' )
}
+
doFirst {
- ext.bundlesTargetDir.mkdirs()
+ project.templateUnpackTargetDirectory.get().asFile.mkdirs()
}
}
-processTestResources.dependsOn copyBundleResources
+task jakartafyTemplates(type: JakartaDirectoryTransformation) {
+ dependsOn tasks.copyTestBundles
-artifacts {
- tests new File(project.buildDir, "libs/hibernate-core-jakarta-${project.version}-test.jar")
+ sourceDirectory = project.templateUnpackTargetDirectory
+ targetDirectory = project.templatesTransformationTargetDirectory
}
-test {
- fileTree(project.buildDir).matching { include 'libs/*-test.jar' }.each {
- def outputDir = file("${buildDir}/unpacked/" + it.name)
- testClassesDirs += files(outputDir)
- classpath += files(outputDir)
+tasks.processTestResources.dependsOn tasks.jakartafyTemplates
+
+tasks.test {
+ ext {
+ combinedDirs = project.files( tasks.jakartafyTests.targetDirectory ) + project.files( tasks.jakartafyTemplates.targetDirectory )
}
+
+ testClassesDirs += combinedDirs
+ classpath += combinedDirs
+
systemProperty 'file.encoding', 'utf-8'
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
@@ -186,4 +223,15 @@ test {
jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
}
-}
\ No newline at end of file
+}
+
+task testJar(type: Jar, dependsOn: testClasses) {
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveClassifier.set( 'test' )
+ from tasks.jakartafyTests.targetDirectory
+ from tasks.jakartafyTemplates.targetDirectory
+}
+
+artifacts {
+ tests tasks.testJar
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java
index 801f735a34..7edc26dfa1 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java
@@ -414,6 +414,20 @@ public class MetadataSources implements Serializable {
return this;
}
+ /**
+ * See {@link #addCacheableFile(java.io.File)} for description
+ *
+ * @param path The path to a file. Expected to be resolvable by {@link java.io.File#File(String)}
+ *
+ * @return this (for method chaining purposes)
+ *
+ * @see #addCacheableFile(java.io.File)
+ */
+ public MetadataSources addCacheableFile(String path, File cacheDirectory) {
+ addCacheableFile( new File( path ), cacheDirectory );
+ return this;
+ }
+
/**
* Add a cached mapping file. A cached file is a serialized representation of the DOM structure of a
* particular mapping. It is saved from a previous call as a file with the name {@code {xmlFile}.bin}
@@ -428,7 +442,24 @@ public class MetadataSources implements Serializable {
* @return this (for method chaining purposes)
*/
public MetadataSources addCacheableFile(File file) {
- final XmlSource xmlSource = XmlSources.fromCacheableFile( file );
+ return addCacheableFile( file, file.getParentFile() );
+ }
+
+ /**
+ * Add a cached mapping file. A cached file is a serialized representation of the DOM structure of a
+ * particular mapping. It is saved from a previous call as a file with the name {@code {xmlFile}.bin}
+ * where {@code {xmlFile}} is the name of the original mapping file.
+ *
+ * If a cached {@code {xmlFile}.bin} exists and is newer than {@code {xmlFile}}, the {@code {xmlFile}.bin}
+ * file will be read directly. Otherwise {@code {xmlFile}} is read and then serialized to {@code {xmlFile}.bin} for
+ * use the next time.
+ *
+ * @param file The cacheable mapping file to be added, {@code {xmlFile}} in above discussion.
+ *
+ * @return this (for method chaining purposes)
+ */
+ public MetadataSources addCacheableFile(File file, File cacheDirectory) {
+ final XmlSource xmlSource = XmlSources.fromCacheableFile( file, cacheDirectory );
final XmlMappingBinderAccess binderAccess = getXmlMappingBinderAccess();
getXmlBindingsForWrite().add( xmlSource.doBind( binderAccess.getMappingBinder() ) );
return this;
@@ -454,6 +485,26 @@ public class MetadataSources implements Serializable {
return this;
}
+ /**
+ * INTENDED FOR TESTSUITE USE ONLY!
+ *
+ * Much like {@link #addCacheableFile(java.io.File)} except that here we will fail immediately if
+ * the cache version cannot be found or used for whatever reason
+ *
+ * @param file The xml file, not the bin!
+ *
+ * @return The dom "deserialized" from the cached file.
+ *
+ * @throws org.hibernate.type.SerializationException Indicates a problem deserializing the cached dom tree
+ * @throws java.io.FileNotFoundException Indicates that the cached file was not found or was not usable.
+ */
+ public MetadataSources addCacheableFileStrictly(File file, File cacheDir) throws SerializationException {
+ final XmlSource xmlSource = XmlSources.fromCacheableFile( file, cacheDir, true );
+ final XmlMappingBinderAccess binderAccess = getXmlMappingBinderAccess();
+ getXmlBindingsForWrite().add( xmlSource.doBind( binderAccess.getMappingBinder() ) );
+ return this;
+ }
+
/**
* Read metadata from an {@link java.io.InputStream} access
*
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java
index 57c203ea8e..2f4aa74682 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/CacheableFileXmlSource.java
@@ -33,12 +33,12 @@ public class CacheableFileXmlSource extends XmlSource {
private final File serFile;
private final boolean strict;
- public CacheableFileXmlSource(Origin origin, File xmlFile, boolean strict) {
+ public CacheableFileXmlSource(Origin origin, File xmlFile, File cachedFileDir, boolean strict) {
super( origin );
this.xmlFile = xmlFile;
this.strict = strict;
- this.serFile = determineCachedFile( xmlFile );
+ this.serFile = new File( cachedFileDir, xmlFile.getName() + ".bin" );
if ( strict ) {
if ( !serFile.exists() ) {
@@ -133,11 +133,15 @@ public class CacheableFileXmlSource extends XmlSource {
}
public static void createSerFile(File xmlFile, Binder binder) {
+ createSerFile( xmlFile, determineCachedFile( xmlFile ), binder );
+ }
+
+ public static void createSerFile(File xmlFile, File outputFile, Binder binder) {
final Origin origin = new Origin( SourceType.FILE, xmlFile.getAbsolutePath() );
writeSerFile(
FileXmlSource.doBind( binder, xmlFile, origin ),
xmlFile,
- determineCachedFile( xmlFile )
+ outputFile
);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/XmlSources.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/XmlSources.java
index 1428a17e26..f1a3242cac 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/XmlSources.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/XmlSources.java
@@ -72,15 +72,23 @@ public class XmlSources {
}
public static XmlSource fromCacheableFile(File file) {
- return fromCacheableFile( file, false );
+ return fromCacheableFile( file, file.getParentFile() );
+ }
+
+ public static XmlSource fromCacheableFile(File file, File cacheableDir) {
+ return fromCacheableFile( file, cacheableDir, false );
}
public static XmlSource fromCacheableFile(File file, boolean strict) {
+ return fromCacheableFile( file, file.getParentFile(), strict );
+ }
+
+ public static XmlSource fromCacheableFile(File file, File cacheableDir, boolean strict) {
final String filePath = file.getPath();
JaxbLogger.JAXB_LOGGER.tracef( "reading mappings from cacheable-file : %s", filePath );
final Origin origin = new Origin( SourceType.FILE, filePath );
- return new CacheableFileXmlSource( origin, file, strict );
+ return new CacheableFileXmlSource( origin, file, cacheableDir, strict );
}
public static XmlSource fromStream(InputStreamAccess inputStreamAccess) {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/CacheableHbmXmlTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/CacheableHbmXmlTest.java
index fea24345cf..121d3fec35 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/CacheableHbmXmlTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/CacheableHbmXmlTest.java
@@ -7,7 +7,6 @@
package org.hibernate.orm.test.bootstrap.binding.hbm.cacheable;
import java.io.File;
-import java.io.FileNotFoundException;
import java.net.URL;
import org.hibernate.boot.MappingException;
@@ -15,15 +14,15 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.jaxb.internal.CacheableFileXmlSource;
import org.hibernate.boot.jaxb.internal.MappingBinder;
import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.XmlMappingBinderAccess;
-import org.hibernate.testing.junit4.BaseUnitTestCase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.ServiceRegistryScope;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Originally developed to help diagnose HHH-10131 - the original tests
@@ -36,23 +35,19 @@ import static org.junit.Assert.fail;
*
* @author Steve Ebersole
*/
-public class CacheableHbmXmlTest extends BaseUnitTestCase {
+@ServiceRegistry()
+public class CacheableHbmXmlTest {
private static final String HBM_RESOURCE_NAME = "org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/SimpleEntity.hbm.xml";
- private StandardServiceRegistry ssr;
- private MappingBinder binder;
+ private static MappingBinder binder;
+ private static File hbmXmlFile;
- private File hbmXmlFile;
- private File hbmXmlBinFile;
+ @BeforeAll
+ public static void prepareFixtures(ServiceRegistryScope scope) throws Exception {
+ binder = new XmlMappingBinderAccess( scope.getRegistry() ).getMappingBinder();
- @Before
- public void before() throws Exception {
- ssr = new StandardServiceRegistryBuilder()
- .build();
- binder = new XmlMappingBinderAccess( ssr ).getMappingBinder();
-
- final URL hbmXmlUrl = getClass().getClassLoader().getResource( HBM_RESOURCE_NAME );
+ final URL hbmXmlUrl = CacheableHbmXmlTest.class.getClassLoader().getResource( HBM_RESOURCE_NAME );
if ( hbmXmlUrl == null ) {
throw couldNotFindHbmXmlResource();
}
@@ -60,32 +55,27 @@ public class CacheableHbmXmlTest extends BaseUnitTestCase {
if ( ! hbmXmlFile.exists() ) {
throw couldNotFindHbmXmlFile( hbmXmlFile );
}
- hbmXmlBinFile = CacheableFileXmlSource.determineCachedFile( hbmXmlFile );
}
- private Exception couldNotFindHbmXmlResource() {
+ private static Exception couldNotFindHbmXmlResource() {
throw new IllegalStateException( "Could not locate `" + HBM_RESOURCE_NAME + "` by resource lookup" );
}
- private Exception couldNotFindHbmXmlFile(File file) {
+ private static Exception couldNotFindHbmXmlFile(File file) {
throw new IllegalStateException(
"File `" + file.getAbsolutePath() + "` resolved from `" + HBM_RESOURCE_NAME + "` resource-lookup does not exist"
);
}
- @After
- public void after() {
- if ( ssr != null ) {
- StandardServiceRegistryBuilder.destroy( ssr );
- }
- }
-
@Test
- public void testStrictCaseWhereFileDoesPreviouslyExist() throws FileNotFoundException {
- deleteBinFile();
- createBinFile();
+ public void testStrictlyWithExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
+ final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
+
+ // create the cacheable file so that it exists before we try to build the boot model
+ createBinFile( binOutputDir );
+
try {
- new MetadataSources( ssr ).addCacheableFileStrictly( hbmXmlFile ).buildMetadata();
+ new MetadataSources( ssr ).addCacheableFileStrictly( hbmXmlFile, binOutputDir ).buildMetadata();
}
catch (MappingException e) {
fail( "addCacheableFileStrictly led to MappingException when bin file existed" );
@@ -93,10 +83,12 @@ public class CacheableHbmXmlTest extends BaseUnitTestCase {
}
@Test
- public void testStrictCaseWhereFileDoesNotPreviouslyExist() throws FileNotFoundException {
- deleteBinFile();
+ public void testStrictlyWithNoExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
try {
- new MetadataSources( ssr ).addCacheableFileStrictly( hbmXmlFile ).buildMetadata();
+ final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
+ new MetadataSources( ssr )
+ .addCacheableFileStrictly( hbmXmlFile, binOutputDir )
+ .buildMetadata();
fail( "addCacheableFileStrictly should be led to MappingException when bin file does not exist" );
}
catch (MappingException ignore) {
@@ -105,34 +97,29 @@ public class CacheableHbmXmlTest extends BaseUnitTestCase {
}
@Test
- public void testNonStrictCaseWhereFileDoesPreviouslyExist() {
- deleteBinFile();
- createBinFile();
- new MetadataSources( ssr ).addCacheableFile( hbmXmlFile ).buildMetadata();
+ public void testNonStrictlyWithExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
+ final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
+
+ // create the cacheable file so that it exists before we try to build the boot model
+ createBinFile( binOutputDir );
+
+ try {
+ new MetadataSources( ssr ).addCacheableFile( hbmXmlFile, binOutputDir ).buildMetadata();
+ }
+ catch (MappingException e) {
+ fail( "addCacheableFileStrictly led to MappingException when bin file existed" );
+ }
}
@Test
- public void testNonStrictCaseWhereFileDoesNotPreviouslyExist() {
- deleteBinFile();
- new MetadataSources( ssr ).addCacheableFile( hbmXmlFile ).buildMetadata();
+ public void testNonStrictlyWithNoExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
+ final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
+ new MetadataSources( ssr ).addCacheableFile( hbmXmlFile, binOutputDir ).buildMetadata();
}
- private void deleteBinFile() {
- // if it exists
- if ( hbmXmlBinFile.exists() ) {
- final boolean success = hbmXmlBinFile.delete();
- if ( !success ) {
- log.warn( "Unable to delete existing cached hbm.xml.bin file", new Exception() );
- }
- }
- }
-
- private void createBinFile() {
- if ( hbmXmlBinFile.exists() ) {
- log.warn( "Cached hbm.xml.bin file already existed on request to create", new Exception() );
- }
- else {
- CacheableFileXmlSource.createSerFile( hbmXmlFile, binder );
- }
+ private void createBinFile(File binOutputDir) {
+ final String outputName = hbmXmlFile.getName() + ".bin";
+ final File file = new File( binOutputDir, outputName );
+ CacheableFileXmlSource.createSerFile( hbmXmlFile, file, binder );
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicUsageTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicUsageTests.java
index 69f737ea46..64eefe3fd2 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicUsageTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicUsageTests.java
@@ -6,28 +6,16 @@
*/
package org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic;
-import org.hibernate.boot.MetadataSources;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.metamodel.mapping.AttributeMapping;
-import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
-import org.hibernate.metamodel.mapping.internal.EmbeddedIdentifierMappingImpl;
-import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
/**
* @author Steve Ebersole
*/
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml
similarity index 100%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml
rename to hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml
similarity index 100%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml
rename to hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml
diff --git a/hibernate-envers-jakarta/hibernate-envers-jakarta.gradle b/hibernate-envers-jakarta/hibernate-envers-jakarta.gradle
index 95155c4946..58d080f38c 100644
--- a/hibernate-envers-jakarta/hibernate-envers-jakarta.gradle
+++ b/hibernate-envers-jakarta/hibernate-envers-jakarta.gradle
@@ -1,4 +1,5 @@
-import org.apache.tools.ant.filters.ReplaceTokens
+import org.hibernate.orm.jakarta.JakartaDirectoryTransformation
+import org.hibernate.orm.jakarta.JakartaJarTransformation
/*
* Hibernate, Relational Persistence for Idiomatic Java
@@ -11,86 +12,115 @@ description = 'Hibernate\'s entity version (audit/history) support Jakarta editi
apply from: rootProject.file( 'gradle/jakarta-java-module.gradle' )
-configurations {
- jakartaeeTransformJars
-}
+evaluationDependsOn( ':hibernate-envers' )
dependencies {
- compile( project( ':hibernate-core-jakarta' ) ) {
+ api( project( ':hibernate-core-jakarta' ) ) {
// Exclude access to this to avoid future use.
exclude group: "org.javassist", module: "javassist"
}
- jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1',
- 'commons-cli:commons-cli:1.4',
- 'org.slf4j:slf4j-simple:1.7.30',
- 'org.slf4j:slf4j-api:1.7.26',
- 'org.eclipse.transformer:org.eclipse.transformer:0.2.0',
- 'org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0'
-
- testCompile( project( ':hibernate-envers-jakarta' ) )
- testCompile( project( ':hibernate-testing-jakarta' ) )
- testCompile( project( path: ':hibernate-core-jakarta', configuration: 'tests' ) )
+ testImplementation( project( ':hibernate-envers-jakarta' ) )
+ testImplementation( project( ':hibernate-testing-jakarta' ) )
+ testImplementation( project( path: ':hibernate-core-jakarta', configuration: 'tests' ) )
}
-jar {
- mustRunAfter project(':hibernate-envers').tasks.jar
- mustRunAfter project(':hibernate-envers').tasks.testJar
- dependsOn project(':hibernate-envers').tasks.jar
- dependsOn project(':hibernate-envers').tasks.testJar
- def baseDir = project(':hibernate-envers').buildDir
- def baseJars = fileTree(baseDir).matching {include 'libs/*.jar' }
- inputs.files(baseJars).skipWhenEmpty()
- outputs.dir project.buildDir
- doLast {
- new File(project.buildDir, "libs").mkdirs()
- fileTree(project.buildDir).matching { include 'libs/*.jar' }.each { delete it }
- baseJars.each { bundleJar ->
- def sourceJarPath = baseDir.path + '/libs/' + bundleJar.name
- println 'Initial bundle jar name [ ' + sourceJarPath + ' ]'
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// main jar
- def finalBundleJarName = project.buildDir.path + '/libs/' + bundleJar.name.replaceAll( 'hibernate-envers', 'hibernate-envers-jakarta' )
- println 'Default jakarta final bundle jar name [ ' + finalBundleJarName + ' ]'
-
- def transformerArgs = [
- sourceJarPath, finalBundleJarName,
- '-q', // quiet output
- '-tr', new File(getProjectDir().getParentFile(), 'rules/jakarta-renames.properties').path,
- '-tv', new File(getProjectDir().getParentFile(), 'rules/jakarta-versions.properties').path,
- '-td', new File(getProjectDir().getParentFile(), 'rules/jakarta-direct.properties').path,
- ]
-
- println 'Transformer options:'
- transformerArgs.each {
- println ' [ ' + it + ' ]'
- }
-
- javaexec {
- classpath configurations.jakartaeeTransformJars
- main = 'org.eclipse.transformer.jakarta.JakartaTransformer'
- args = transformerArgs
- }
- }
- }
+tasks.jar {
+ enabled false
}
-task unpackTestJar(type: Copy) {
- dependsOn jar
- fileTree(project.buildDir).matching { include 'libs/*-test.jar' }.each {
- def outputDir = file("${buildDir}/unpacked/" + it.name)
- from zipTree(it)
- into outputDir
- }
+task jakartafyJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-envers').tasks.jar.archiveFile
+ targetJar = tasks.jar.archiveFile
}
-test {
- dependsOn unpackTestJar
- fileTree(project.buildDir).matching { include 'libs/*-test.jar' }.each {
- def outputDir = file("${buildDir}/unpacked/" + it.name)
- testClassesDirs += files(outputDir)
- classpath += files(outputDir)
- }
+tasks.jar.dependsOn project(':hibernate-envers').tasks.jar
+tasks.jar.finalizedBy tasks.jakartafyJar
+tasks.jakartafyJar.dependsOn tasks.jar
+tasks.jakartafyJar.mustRunAfter tasks.jar
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// javadoc jar
+
+tasks.javadocJar {
+ enabled false
+}
+
+task jakartafyJavadocJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-envers').tasks.javadocJar.archiveFile
+ targetJar = tasks.javadocJar.archiveFile
+}
+
+tasks.javadocJar.dependsOn project(':hibernate-envers').tasks.javadocJar
+tasks.javadocJar.finalizedBy tasks.jakartafyJavadocJar
+tasks.jakartafyJavadocJar.dependsOn tasks.javadocJar
+tasks.jakartafyJavadocJar.mustRunAfter tasks.javadocJar
+
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// sources jar
+
+tasks.sourcesJar {
+ enabled false
+}
+
+task jakartafySourcesJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-envers').tasks.sourcesJar.archiveFile
+ targetJar = tasks.javadocJar.archiveFile
+}
+
+tasks.sourcesJar.dependsOn project(':hibernate-envers').tasks.sourcesJar
+tasks.sourcesJar.finalizedBy tasks.jakartafySourcesJar
+tasks.jakartafySourcesJar.dependsOn tasks.sourcesJar
+tasks.jakartafySourcesJar.mustRunAfter tasks.sourcesJar
+
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// testing
+
+project.ext {
+ testClassesUnpackTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/unpack/classes' )
+ testClassesTransformationTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/test/classes' )
+}
+
+tasks.compileTestJava {
+ enabled false
+}
+
+tasks.processTestResources {
+ enabled false
+}
+
+task unpackTests(type: Copy) {
+ from zipTree( project( ':hibernate-envers' ).tasks.testJar.archiveFile )
+ into project.testClassesUnpackTargetDirectory
+}
+
+task jakartafyTests(type: JakartaDirectoryTransformation) {
+ sourceDirectory = project.testClassesUnpackTargetDirectory
+ targetDirectory = project.testClassesTransformationTargetDirectory
+}
+
+
+tasks.compileTestJava.dependsOn tasks.unpackTests
+tasks.compileTestJava.finalizedBy tasks.jakartafyTests
+
+tasks.unpackTests.dependsOn project(':hibernate-envers').tasks.testJar
+
+tasks.jakartafyTests.dependsOn tasks.unpackTests
+
+tasks.test {
+ dependsOn tasks.jakartafyTests
+ testClassesDirs += project.files( tasks.jakartafyTests.targetDirectory )
+ classpath += project.files( tasks.jakartafyTests.targetDirectory )
+
systemProperty 'file.encoding', 'utf-8'
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
@@ -100,4 +130,16 @@ test {
jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
}
-}
\ No newline at end of file
+}
+
+tasks.test.dependsOn project( ':hibernate-transaction-client' ).tasks.jar
+
+task testJar(type: Jar, dependsOn: testClasses) {
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveClassifier.set( 'test' )
+ from sourceSets.test.output
+}
+
+artifacts {
+ tests tasks.testJar
+}
diff --git a/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle b/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle
index edb32619e7..da2025d0a4 100644
--- a/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle
+++ b/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle
@@ -1,3 +1,6 @@
+import org.hibernate.orm.jakarta.JakartaDirectoryTransformation
+import org.hibernate.orm.jakarta.JakartaJarTransformation
+
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@@ -7,11 +10,10 @@
description = 'Support for testing Hibernate ORM Jakarta functionality'
+
apply from: rootProject.file( 'gradle/jakarta-java-module.gradle' )
-configurations {
- jakartaeeTransformJars
-}
+evaluationDependsOn( ':hibernate-testing' )
dependencies {
api project( ':hibernate-core-jakarta' )
@@ -37,51 +39,124 @@ dependencies {
api libraries.log4j2
- jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1',
- 'commons-cli:commons-cli:1.4',
- 'org.slf4j:slf4j-simple:1.7.30',
- 'org.slf4j:slf4j-api:1.7.26',
- 'org.eclipse.transformer:org.eclipse.transformer:0.2.0',
- 'org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0'
- testCompile fileTree(dir: 'libs', include: '*.jar')
+ implementation project( ':hibernate-transaction-client' )
+
+ testImplementation fileTree(dir: 'libs', include: '*.jar')
}
-jar {
- mustRunAfter project(':hibernate-testing').tasks.jar
- dependsOn project(':hibernate-testing').tasks.jar
- def baseDir = project(':hibernate-testing').buildDir
- def baseJars = fileTree(baseDir).matching {include 'libs/*.jar' }
- inputs.files(baseJars).skipWhenEmpty()
- outputs.dir project.buildDir
- doLast {
- new File(project.buildDir, "libs").mkdirs()
- fileTree(project.buildDir).matching { include 'libs/*.jar' }.each { delete it }
- baseJars.each { bundleJar ->
- def sourceJarPath = baseDir.path + '/libs/' + bundleJar.name
- println 'Initial bundle jar name [ ' + sourceJarPath + ' ]'
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// main jar
- def finalBundleJarName = project.buildDir.path + '/libs/' + bundleJar.name.replaceAll( 'hibernate-testing', 'hibernate-testing-jakarta' )
- println 'Default jakarta final bundle jar name [ ' + finalBundleJarName + ' ]'
+tasks.jar {
+ enabled false
+}
- def transformerArgs = [
- sourceJarPath, finalBundleJarName,
- '-q', // quiet output
- '-tr', new File(getProjectDir().getParentFile(), 'rules/jakarta-renames.properties').path,
- '-tv', new File(getProjectDir().getParentFile(), 'rules/jakarta-versions.properties').path,
- '-td', new File(getProjectDir().getParentFile(), 'rules/jakarta-direct.properties').path,
- ]
+task jakartafyJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-testing').tasks.jar.archiveFile
+ targetJar = tasks.jar.archiveFile
+}
- println 'Transformer options:'
- transformerArgs.each {
- println ' [ ' + it + ' ]'
- }
+tasks.jar.dependsOn project(':hibernate-testing').tasks.jar
+tasks.jar.finalizedBy tasks.jakartafyJar
+tasks.jakartafyJar.dependsOn tasks.jar
+tasks.jakartafyJar.mustRunAfter tasks.jar
- javaexec {
- classpath configurations.jakartaeeTransformJars
- main = 'org.eclipse.transformer.jakarta.JakartaTransformer'
- args = transformerArgs
- }
- }
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// javadoc jar
+
+tasks.javadocJar {
+ enabled false
+}
+
+task jakartafyJavadocJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-testing').tasks.javadocJar.archiveFile
+ targetJar = tasks.javadocJar.archiveFile
+}
+
+tasks.javadocJar.dependsOn project(':hibernate-testing').tasks.javadocJar
+tasks.javadocJar.finalizedBy tasks.jakartafyJavadocJar
+tasks.jakartafyJavadocJar.dependsOn tasks.javadocJar
+tasks.jakartafyJavadocJar.mustRunAfter tasks.javadocJar
+
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// sources jar
+
+tasks.sourcesJar {
+ enabled false
+}
+
+task jakartafySourcesJar( type: JakartaJarTransformation ) {
+ sourceJar = project(':hibernate-testing').tasks.sourcesJar.archiveFile
+ targetJar = tasks.javadocJar.archiveFile
+}
+
+tasks.sourcesJar.dependsOn project(':hibernate-testing').tasks.sourcesJar
+tasks.sourcesJar.finalizedBy tasks.jakartafySourcesJar
+tasks.jakartafySourcesJar.dependsOn tasks.sourcesJar
+tasks.jakartafySourcesJar.mustRunAfter tasks.sourcesJar
+
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// testing
+
+project.ext {
+ testClassesUnpackTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/unpack/classes' )
+ testClassesTransformationTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/test/classes' )
+}
+
+tasks.compileTestJava {
+ enabled false
+}
+
+tasks.processTestResources {
+ enabled false
+}
+
+task unpackTests(type: Copy) {
+ from zipTree( project( ':hibernate-testing' ).tasks.testJar.archiveFile )
+ into project.testClassesUnpackTargetDirectory
+}
+
+task jakartafyTests(type: JakartaDirectoryTransformation) {
+ sourceDirectory = project.testClassesUnpackTargetDirectory
+ targetDirectory = project.testClassesTransformationTargetDirectory
+}
+
+
+tasks.compileTestJava.dependsOn tasks.unpackTests
+tasks.compileTestJava.finalizedBy tasks.jakartafyTests
+
+tasks.unpackTests.dependsOn project(':hibernate-testing').tasks.testJar
+
+tasks.jakartafyTests.dependsOn tasks.unpackTests
+
+tasks.test {
+ testClassesDirs += project.files( tasks.jakartafyTests.targetDirectory )
+ classpath += project.files( tasks.jakartafyTests.targetDirectory )
+
+ systemProperty 'file.encoding', 'utf-8'
+
+ if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
+ // See org.hibernate.boot.model.naming.NamingHelperTest.DefaultCharset.set
+ jvmArgs( ['--add-opens', 'java.base/java.nio.charset=ALL-UNNAMED'] )
+ // Weld needs this to generate proxies
+ jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
+ jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
}
}
+
+task testJar(type: Jar, dependsOn: testClasses) {
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveClassifier.set( 'test' )
+ from tasks.jakartafyTests.targetDirectory
+}
+
+artifacts {
+ tests tasks.testJar
+}
+
diff --git a/hibernate-testing/hibernate-testing.gradle b/hibernate-testing/hibernate-testing.gradle
index ec013141f1..311d4bec0d 100644
--- a/hibernate-testing/hibernate-testing.gradle
+++ b/hibernate-testing/hibernate-testing.gradle
@@ -9,6 +9,9 @@ description = 'Support for testing Hibernate ORM functionality'
apply from: rootProject.file( 'gradle/published-java-module.gradle' )
+configurations {
+ tests
+}
dependencies {
api project( ':hibernate-core' )
@@ -37,4 +40,14 @@ dependencies {
tasks.test.include '**/*'
+task testJar(type: Jar, dependsOn: testClasses) {
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+ archiveClassifier.set( 'test' )
+ from sourceSets.test.output
+}
+
+artifacts {
+ tests tasks.testJar
+}
+
diff --git a/hibernate-transaction-client/hibernate-transaction-client.gradle b/hibernate-transaction-client/hibernate-transaction-client.gradle
index 2341fccede..40edaf83e3 100644
--- a/hibernate-transaction-client/hibernate-transaction-client.gradle
+++ b/hibernate-transaction-client/hibernate-transaction-client.gradle
@@ -4,6 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
+import org.hibernate.orm.jakarta.JakartaJarTransformation
description = 'Wildfly Transaction Client transformed to be JTA 2.0 compatible'
@@ -16,53 +17,27 @@ tasks.withType(PublishToMavenRepository) {
}
configurations {
- jakartaeeTransformJars
+ wildFlyTxnClient {
+ description = 'Used to access the WildFly transaction client jar to be able to transform it'
+ }
}
dependencies {
- compile( libraries.jakarta_jta )
+ api libraries.jakarta_jta
- jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1',
- 'commons-cli:commons-cli:1.4',
- 'org.slf4j:slf4j-simple:1.7.30',
- 'org.slf4j:slf4j-api:1.7.26',
- 'org.eclipse.transformer:org.eclipse.transformer:0.2.0',
- 'org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0'
- testCompile ( libraries.wildfly_transaction_client ) {
- transitive=false;
+ wildFlyTxnClient( libraries.wildfly_transaction_client ) {
+ transitive = false;
}
}
-jar {
- def sourceJarPath = project.configurations.testCompile.find { it.name.startsWith("wildfly-transaction-client-") }
- inputs.files(sourceJarPath).skipWhenEmpty()
- outputs.dir project.buildDir
- doLast {
- new File(project.buildDir, "libs").mkdirs()
- fileTree(project.buildDir).matching { include 'libs/*.jar' }.each { delete it }
+tasks.compileJava.enabled = false
+tasks.processResources.enabled = false
+tasks.compileTestJava.enabled = false
+tasks.processTestResources.enabled = false
+tasks.test.enabled = false
+tasks.jar.enabled = false
- println 'Initial bundle jar name [ ' + sourceJarPath + ' ]'
-
- def finalBundleJarName = project.buildDir.path + '/libs/hibernate-transaction-client-' + project.version + ".jar"
- println 'Default jakarta final bundle jar name [ ' + finalBundleJarName + ' ]'
-
- def transformerArgs = [
- sourceJarPath, finalBundleJarName,
- '-q', // quiet output
- '-tr', new File(getProjectDir().getParentFile(), 'rules/jakarta-renames.properties').path,
- '-tv', new File(getProjectDir().getParentFile(), 'rules/jakarta-versions.properties').path,
- '-td', new File(getProjectDir().getParentFile(), 'rules/jakarta-direct.properties').path,
- ]
-
- println 'Transformer options:'
- transformerArgs.each {
- println ' [ ' + it + ' ]'
- }
-
- javaexec {
- classpath configurations.jakartaeeTransformJars
- main = 'org.eclipse.transformer.jakarta.JakartaTransformer'
- args = transformerArgs
- }
- }
+task jakartafyDependency(type: JakartaJarTransformation) {
+ sourceJar = project.configurations.wildFlyTxnClient.resolvedConfiguration.resolvedArtifacts.find().file
+ targetJar = tasks.jar.archiveFile
}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 46bce61947..2390ddfd4c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -12,6 +12,8 @@ plugins {
rootProject.name = 'hibernate-orm'
+includeBuild('database-service-plugin')
+
apply from: file( 'gradle/gradle-enterprise.gradle' )
if ( !JavaVersion.current().java8Compatible ) {
@@ -147,7 +149,6 @@ project(':hibernate-gradle-plugin').projectDir = new File(rootProject.projectDir
include 'hibernate-enhance-maven-plugin'
project(':hibernate-enhance-maven-plugin').projectDir = new File(rootProject.projectDir, "tooling/hibernate-enhance-maven-plugin")
-includeBuild('database-service-plugin')
rootProject.children.each { project ->
project.buildFileName = "${project.name}.gradle"
diff --git a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle
index f3ddf4a63e..0430bfc03e 100644
--- a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle
+++ b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle
@@ -11,7 +11,7 @@ plugins {
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '0.14.0'
- id 'com.github.sebersole.testkit-junit5' version '1.0.1'
+ id 'com.github.sebersole.testkit-junit5' version '1.2.0'
}
apply from: rootProject.file( 'gradle/java-module.gradle' )
diff --git a/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle b/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle
index 07e579005c..d83e7b0c58 100644
--- a/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle
+++ b/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle
@@ -15,8 +15,8 @@ configurations {
dependencies {
// JAXB
- compile( libraries.jakarta_jaxb_api )
- compile( libraries.jakarta_jaxb_runtime )
+ implementation( libraries.jakarta_jaxb_api )
+ implementation( libraries.jakarta_jaxb_runtime )
jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1',
'commons-cli:commons-cli:1.4',
@@ -24,7 +24,7 @@ dependencies {
'org.slf4j:slf4j-api:1.7.26',
'org.eclipse.transformer:org.eclipse.transformer:0.2.0',
'org.eclipse.transformer:org.eclipse.transformer.cli:0.2.0'
- testCompile fileTree(dir: 'libs', include: '*.jar')
+ testImplementation fileTree(dir: 'libs', include: '*.jar')
}
jar {