diff --git a/hibernate-core-jakarta/hibernate-core-jakarta.gradle b/hibernate-core-jakarta/hibernate-core-jakarta.gradle index 09e3e1bd5d..802fea1831 100644 --- a/hibernate-core-jakarta/hibernate-core-jakarta.gradle +++ b/hibernate-core-jakarta/hibernate-core-jakarta.gradle @@ -94,6 +94,8 @@ processResources.enabled false compileTestJava.enabled false processTestResources.enabled false jar.enabled false +javadocJar.enabled false +sourcesJar.enabled false ext { transformedJarName = project(':hibernate-core').tasks.jar.archiveFileName.get().replaceAll( 'hibernate-core', 'hibernate-core-jakarta' ) @@ -123,6 +125,26 @@ task transformJar(type: JakartaJarTransformation) { targetJar tasks.jar.archiveFile.get().asFile } +task transformSourcesJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-core sources jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-core').tasks.sourcesJar + mustRunAfter project(':hibernate-core').tasks.sourcesJar + + sourceJar project(':hibernate-core').tasks.sourcesJar.archiveFile + targetJar tasks.sourcesJar.archiveFile.get().asFile +} + +task transformJavadocJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-core javadoc jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-core').tasks.javadocJar + mustRunAfter project(':hibernate-core').tasks.javadocJar + + sourceJar project(':hibernate-core').tasks.javadocJar.archiveFile + targetJar tasks.javadocJar.archiveFile.get().asFile +} + configurations { [apiElements, runtimeElements].each { it.outgoing.artifacts.removeIf { @@ -131,6 +153,12 @@ configurations { it.outgoing.artifact(tasks.transformJar.targetJar) { builtBy tasks.transformJar } + it.outgoing.artifact(tasks.transformSourcesJar.targetJar) { + builtBy tasks.transformSourcesJar + } + it.outgoing.artifact(tasks.transformJavadocJar.targetJar) { + builtBy tasks.transformJavadocJar + } } } diff --git a/hibernate-envers-jakarta/hibernate-envers-jakarta.gradle b/hibernate-envers-jakarta/hibernate-envers-jakarta.gradle index 0a72f9ef9d..4841a1e8bb 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 javax.inject.Inject /* * Hibernate, Relational Persistence for Idiomatic Java @@ -12,13 +13,22 @@ description = 'Hibernate\'s entity version (audit/history) support Jakarta editi apply from: rootProject.file( 'gradle/published-java-module.gradle' ) configurations { - jakartaeeTransformJars + jakartaeeTransformTool } +// we do not want the much of the normal java plugin's behavior +compileJava.enabled false +processResources.enabled false +compileTestJava.enabled false +processTestResources.enabled false +jar.enabled false +javadocJar.enabled false +sourcesJar.enabled false + dependencies { compile( project( ':hibernate-core-jakarta' ) ) - jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1', + jakartaeeTransformTool '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', @@ -64,7 +74,7 @@ jar { } javaexec { - classpath configurations.jakartaeeTransformJars + classpath configurations.jakartaeeTransformTool main = 'org.eclipse.transformer.jakarta.JakartaTransformer' args = transformerArgs } @@ -72,6 +82,53 @@ jar { } } +task transformJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-envers jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-envers').tasks.jar + mustRunAfter project(':hibernate-envers').tasks.jar + + sourceJar project(':hibernate-envers').tasks.jar.archiveFile + targetJar tasks.jar.archiveFile.get().asFile +} + +task transformSourcesJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-envers sources jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-envers').tasks.sourcesJar + mustRunAfter project(':hibernate-envers').tasks.sourcesJar + + sourceJar project(':hibernate-envers').tasks.sourcesJar.archiveFile + targetJar tasks.sourcesJar.archiveFile.get().asFile +} + +task transformJavadocJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-envers javadoc jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-envers').tasks.javadocJar + mustRunAfter project(':hibernate-envers').tasks.javadocJar + + sourceJar project(':hibernate-envers').tasks.javadocJar.archiveFile + targetJar tasks.javadocJar.archiveFile.get().asFile +} + +configurations { + [apiElements, runtimeElements].each { + it.outgoing.artifacts.removeIf { + it.buildDependencies.getDependencies(null).contains(jar) + } + it.outgoing.artifact(tasks.transformJar.targetJar) { + builtBy tasks.transformJar + } + it.outgoing.artifact(tasks.transformSourcesJar.targetJar) { + builtBy tasks.transformSourcesJar + } + it.outgoing.artifact(tasks.transformJavadocJar.targetJar) { + builtBy tasks.transformJavadocJar + } + } +} + task unpackTestJar(type: Copy) { dependsOn jar fileTree(project.buildDir).matching { include 'libs/*-test.jar' }.each { @@ -98,3 +155,53 @@ test { jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] ) } } + +@CacheableTask +abstract class JakartaJarTransformation extends DefaultTask { + private final RegularFileProperty sourceJar; + private final RegularFileProperty targetJar; + + @Inject + JakartaJarTransformation(ObjectFactory objectFactory) { + sourceJar = objectFactory.fileProperty(); + targetJar = objectFactory.fileProperty(); + } + + @InputFile + @PathSensitive( PathSensitivity.RELATIVE ) + RegularFileProperty getSourceJar() { + return sourceJar; + } + + void sourceJar(Object fileReference) { + sourceJar.set( project.file( fileReference ) ) + } + + @OutputFile + RegularFileProperty getTargetJar() { + return targetJar; + } + + void targetJar(Object fileReference) { + targetJar.set( project.file( fileReference ) ) + } + + @TaskAction + void transform() { + project.javaexec( new Action() { + @Override + void execute(JavaExecSpec 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() + ); + } + }); + } +} \ No newline at end of file diff --git a/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle b/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle index e734d0acbd..de795aa1d2 100644 --- a/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle +++ b/hibernate-testing-jakarta/hibernate-testing-jakarta.gradle @@ -1,3 +1,5 @@ +import javax.inject.Inject + /* * Hibernate, Relational Persistence for Idiomatic Java * @@ -10,9 +12,18 @@ description = 'Support for testing Hibernate ORM Jakarta functionality' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) configurations { - jakartaeeTransformJars + jakartaeeTransformTool } +// we do not want the much of the normal java plugin's behavior +compileJava.enabled false +processResources.enabled false +compileTestJava.enabled false +processTestResources.enabled false +jar.enabled false +javadocJar.enabled false +sourcesJar.enabled false + dependencies { compile project( ':hibernate-core-jakarta' ) compile( libraries.jakarta_jta ) @@ -29,7 +40,7 @@ dependencies { transitive=false; } - jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1', + jakartaeeTransformTool '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', @@ -70,10 +81,107 @@ jar { } javaexec { - classpath configurations.jakartaeeTransformJars + classpath configurations.jakartaeeTransformTool main = 'org.eclipse.transformer.jakarta.JakartaTransformer' args = transformerArgs } } } } + +task transformJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-testing jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-testing').tasks.jar + mustRunAfter project(':hibernate-testing').tasks.jar + + sourceJar project(':hibernate-testing').tasks.jar.archiveFile + targetJar tasks.jar.archiveFile.get().asFile +} + +task transformSourcesJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-testing sources jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-testing').tasks.sourcesJar + mustRunAfter project(':hibernate-testing').tasks.sourcesJar + + sourceJar project(':hibernate-testing').tasks.sourcesJar.archiveFile + targetJar tasks.sourcesJar.archiveFile.get().asFile +} + +task transformJavadocJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-testing javadoc jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-testing').tasks.javadocJar + mustRunAfter project(':hibernate-testing').tasks.javadocJar + + sourceJar project(':hibernate-testing').tasks.javadocJar.archiveFile + targetJar tasks.javadocJar.archiveFile.get().asFile +} + +configurations { + [apiElements, runtimeElements].each { + it.outgoing.artifacts.removeIf { + it.buildDependencies.getDependencies(null).contains(jar) + } + it.outgoing.artifact(tasks.transformJar.targetJar) { + builtBy tasks.transformJar + } + it.outgoing.artifact(tasks.transformSourcesJar.targetJar) { + builtBy tasks.transformSourcesJar + } + it.outgoing.artifact(tasks.transformJavadocJar.targetJar) { + builtBy tasks.transformJavadocJar + } + } +} + +@CacheableTask +abstract class JakartaJarTransformation extends DefaultTask { + private final RegularFileProperty sourceJar; + private final RegularFileProperty targetJar; + + @Inject + JakartaJarTransformation(ObjectFactory objectFactory) { + sourceJar = objectFactory.fileProperty(); + targetJar = objectFactory.fileProperty(); + } + + @InputFile + @PathSensitive( PathSensitivity.RELATIVE ) + RegularFileProperty getSourceJar() { + return sourceJar; + } + + void sourceJar(Object fileReference) { + sourceJar.set( project.file( fileReference ) ) + } + + @OutputFile + RegularFileProperty getTargetJar() { + return targetJar; + } + + void targetJar(Object fileReference) { + targetJar.set( project.file( fileReference ) ) + } + + @TaskAction + void transform() { + project.javaexec( new Action() { + @Override + void execute(JavaExecSpec 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/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle b/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle index 13d32b6685..ac9a622e81 100644 --- a/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle +++ b/tooling/metamodel-generator-jakarta/hibernate-jpamodelgen-jakarta.gradle @@ -1,3 +1,5 @@ +import javax.inject.Inject + /* * Hibernate, Relational Persistence for Idiomatic Java * @@ -10,15 +12,24 @@ description = 'Annotation Processor to generate JPA 3 static metamodel classes' apply from: rootProject.file( 'gradle/published-java-module.gradle' ) configurations { - jakartaeeTransformJars + jakartaeeTransformTool } +// we do not want the much of the normal java plugin's behavior +compileJava.enabled false +processResources.enabled false +compileTestJava.enabled false +processTestResources.enabled false +jar.enabled false +javadocJar.enabled false +sourcesJar.enabled false + dependencies { // JAXB compile( libraries.jakarta_jaxb_api ) compile( libraries.jakarta_jaxb_runtime ) - jakartaeeTransformJars 'biz.aQute.bnd:biz.aQute.bnd.transform:5.1.1', + jakartaeeTransformTool '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', @@ -59,10 +70,107 @@ jar { } javaexec { - classpath configurations.jakartaeeTransformJars + classpath configurations.jakartaeeTransformTool main = 'org.eclipse.transformer.jakarta.JakartaTransformer' args = transformerArgs } } } +} + +task transformJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-jpamodelgen jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-jpamodelgen').tasks.jar + mustRunAfter project(':hibernate-jpamodelgen').tasks.jar + + sourceJar project(':hibernate-jpamodelgen').tasks.jar.archiveFile + targetJar tasks.jar.archiveFile.get().asFile +} + +task transformSourcesJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-jpamodelgen sources jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-jpamodelgen').tasks.sourcesJar + mustRunAfter project(':hibernate-jpamodelgen').tasks.sourcesJar + + sourceJar project(':hibernate-jpamodelgen').tasks.sourcesJar.archiveFile + targetJar tasks.sourcesJar.archiveFile.get().asFile +} + +task transformJavadocJar(type: JakartaJarTransformation) { + description 'Transforms the hibernate-jpamodelgen javadoc jar using the JakartaTransformer tool' + + dependsOn project(':hibernate-jpamodelgen').tasks.javadocJar + mustRunAfter project(':hibernate-jpamodelgen').tasks.javadocJar + + sourceJar project(':hibernate-jpamodelgen').tasks.javadocJar.archiveFile + targetJar tasks.javadocJar.archiveFile.get().asFile +} + +configurations { + [apiElements, runtimeElements].each { + it.outgoing.artifacts.removeIf { + it.buildDependencies.getDependencies(null).contains(jar) + } + it.outgoing.artifact(tasks.transformJar.targetJar) { + builtBy tasks.transformJar + } + it.outgoing.artifact(tasks.transformSourcesJar.targetJar) { + builtBy tasks.transformSourcesJar + } + it.outgoing.artifact(tasks.transformJavadocJar.targetJar) { + builtBy tasks.transformJavadocJar + } + } +} + +@CacheableTask +abstract class JakartaJarTransformation extends DefaultTask { + private final RegularFileProperty sourceJar; + private final RegularFileProperty targetJar; + + @Inject + JakartaJarTransformation(ObjectFactory objectFactory) { + sourceJar = objectFactory.fileProperty(); + targetJar = objectFactory.fileProperty(); + } + + @InputFile + @PathSensitive( PathSensitivity.RELATIVE ) + RegularFileProperty getSourceJar() { + return sourceJar; + } + + void sourceJar(Object fileReference) { + sourceJar.set( project.file( fileReference ) ) + } + + @OutputFile + RegularFileProperty getTargetJar() { + return targetJar; + } + + void targetJar(Object fileReference) { + targetJar.set( project.file( fileReference ) ) + } + + @TaskAction + void transform() { + project.javaexec( new Action() { + @Override + void execute(JavaExecSpec 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() + ); + } + }); + } } \ No newline at end of file