HHH-14817 Make sure *-jakarta modules generate source and javadoc jars

This commit is contained in:
Christian Beikov 2022-03-08 18:28:02 +01:00
parent 9554ab9e41
commit c5e95e5a34
4 changed files with 360 additions and 9 deletions

View File

@ -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
}
}
}

View File

@ -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<JavaExecSpec>() {
@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()
);
}
});
}
}

View File

@ -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<JavaExecSpec>() {
@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()
);
}
});
}
}

View File

@ -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<JavaExecSpec>() {
@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()
);
}
});
}
}