Fix Jakarta processing
This commit is contained in:
parent
e13e0bc9d5
commit
174b23001f
|
@ -5,16 +5,18 @@
|
|||
* 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
|
||||
*/
|
||||
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
||||
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
|
||||
apply plugin: 'org.hibernate.orm.jakarta'
|
||||
|
||||
apply from: rootProject.file( 'gradle/libraries.gradle' )
|
||||
apply from: rootProject.file( 'gradle/databases.gradle' )
|
||||
apply plugin: 'org.hibernate.orm.database-service'
|
||||
apply plugin: 'build-dashboard'
|
||||
apply plugin: 'project-report'
|
||||
|
||||
configurations {
|
||||
jakartaeeTransformTool {
|
||||
description = 'JakartaTransformer tool dependencies'
|
||||
}
|
||||
tests {
|
||||
description = 'Configuration for the produced test jar'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -26,26 +28,3 @@ tasks.withType( Test ) { test ->
|
|||
test.usesService( project.gradle.sharedServices.registrations.getByName( 'databaseService' ).service )
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publishedArtifacts {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Release / publishing tasks
|
||||
|
||||
task ciBuild( dependsOn: [test, publish] )
|
||||
|
||||
task release(dependsOn: [test, publishToSonatype])
|
||||
publishToSonatype.mustRunAfter test
|
||||
|
||||
|
||||
|
|
|
@ -54,12 +54,6 @@ if ( !project.description ) {
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Configurations and Dependencies
|
||||
|
||||
configurations {
|
||||
provided {
|
||||
description = 'Non-exported compile-time dependencies.'
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all*.exclude group: 'xml-apis', module: 'xml-apis'
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
apply from: rootProject.file( 'gradle/jakarta-java-module.gradle' )
|
||||
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
|
||||
apply plugin: 'org.hibernate.orm.jakarta-publish'
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publishedArtifacts {
|
||||
from components.jakarta
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//java {
|
||||
// withJavadocJar()
|
||||
// withSourcesJar()
|
||||
//}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Release / publishing tasks
|
||||
|
||||
task ciBuild( dependsOn: [test, publish] )
|
||||
|
||||
task release(dependsOn: [test, publishToSonatype])
|
||||
publishToSonatype.mustRunAfter test
|
||||
|
||||
|
|
@ -1,17 +1,12 @@
|
|||
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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
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' )
|
||||
apply from: rootProject.file( 'gradle/published-jakarta-java-module.gradle' )
|
||||
|
||||
evaluationDependsOn( ':hibernate-core' )
|
||||
|
||||
|
@ -84,58 +79,58 @@ dependencies {
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// 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
|
||||
//
|
||||
//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
|
||||
//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
|
||||
|
||||
//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
|
||||
//
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -149,36 +144,42 @@ project.ext {
|
|||
templatesTransformationTargetDirectory = project.layout.buildDirectory.dir( 'jakarta/test/templates' )
|
||||
}
|
||||
|
||||
tasks.compileTestJava {
|
||||
enabled false
|
||||
dependsOn project(':hibernate-core').tasks.compileTestJava
|
||||
dependsOn
|
||||
}
|
||||
//tasks.compileTestJava {
|
||||
// enabled false
|
||||
// dependsOn project(':hibernate-core').tasks.compileTestJava
|
||||
// dependsOn
|
||||
//}
|
||||
//
|
||||
//tasks.processTestResources {
|
||||
// enabled false
|
||||
// dependsOn project(':hibernate-core').tasks.compileTestJava
|
||||
//}
|
||||
//
|
||||
//task unpackTests(type: Copy) {
|
||||
// from project( ':hibernate-core' ).sourceSets.test.output
|
||||
//// from zipTree( project( ':hibernate-core' ).tasks.testJar.archiveFile )
|
||||
// into project.testClassesUnpackTargetDirectory
|
||||
// exclude 'templates/**'
|
||||
//}
|
||||
//
|
||||
//task jakartafyTests(type: JakartaDirectoryTransformation) {
|
||||
// sourceDirectory = project.testClassesUnpackTargetDirectory
|
||||
// targetDirectory = project.testClassesTransformationTargetDirectory
|
||||
//
|
||||
// dependsOn 'compileTestJava'
|
||||
// dependsOn 'unpackTests'
|
||||
//}
|
||||
|
||||
tasks.processTestResources {
|
||||
enabled false
|
||||
dependsOn project(':hibernate-core').tasks.compileTestJava
|
||||
}
|
||||
|
||||
task unpackTests(type: Copy) {
|
||||
from project( ':hibernate-core' ).sourceSets.test.output
|
||||
// from zipTree( project( ':hibernate-core' ).tasks.testJar.archiveFile )
|
||||
into project.testClassesUnpackTargetDirectory
|
||||
exclude 'templates/**'
|
||||
}
|
||||
|
||||
task jakartafyTests(type: JakartaDirectoryTransformation) {
|
||||
sourceDirectory = project.testClassesUnpackTargetDirectory
|
||||
targetDirectory = project.testClassesTransformationTargetDirectory
|
||||
|
||||
dependsOn 'compileTestJava'
|
||||
dependsOn 'unpackTests'
|
||||
}
|
||||
|
||||
tasks.test.dependsOn tasks.jakartafyTests
|
||||
//tasks.test.dependsOn tasks.jakartafyTests
|
||||
//tasks.jakartafyTests.dependsOn tasks.unpackTests
|
||||
//tasks.unpackTests.dependsOn project( ':hibernate-core' ).tasks.testJar
|
||||
|
||||
tasks.collectTests {
|
||||
exclude 'templates/**'
|
||||
}
|
||||
|
||||
final Provider<Directory> bundleCollectDir = project.getLayout().getBuildDirectory().dir( "jakarta/collect/bundles" );
|
||||
final Provider<Directory> bundleTransformedDir = project.getLayout().getBuildDirectory().dir( "jakarta/transformed/bundles" );
|
||||
|
||||
task copyTestBundles(type: Copy) {
|
||||
// `:hibernate-core:processTestResources` also triggers processing the
|
||||
|
@ -187,10 +188,10 @@ task copyTestBundles(type: Copy) {
|
|||
dependsOn project( ':hibernate-core' ).tasks.processTestResources
|
||||
|
||||
inputs.dir project( ':hibernate-core' ).layout.buildDirectory.dir( 'bundles' )
|
||||
outputs.dir project.templateUnpackTargetDirectory
|
||||
outputs.dir bundleCollectDir
|
||||
|
||||
from project( ':hibernate-core' ).layout.buildDirectory.dir( 'bundles' )
|
||||
into project.templateUnpackTargetDirectory
|
||||
into bundleCollectDir
|
||||
|
||||
// There are persistence.xml files referencing jar files through their absolute path so we
|
||||
// have to replace 'hibernate-core' references in the path with 'hibernate-core-jakarta'
|
||||
|
@ -199,26 +200,21 @@ task copyTestBundles(type: Copy) {
|
|||
}
|
||||
|
||||
doFirst {
|
||||
project.templateUnpackTargetDirectory.get().asFile.mkdirs()
|
||||
bundleCollectDir.get().asFile.mkdirs()
|
||||
}
|
||||
}
|
||||
|
||||
task jakartafyTemplates(type: JakartaDirectoryTransformation) {
|
||||
dependsOn tasks.copyTestBundles
|
||||
dependsOn tasks.jakartafyTests
|
||||
|
||||
sourceDirectory = project.templateUnpackTargetDirectory
|
||||
targetDirectory = project.templatesTransformationTargetDirectory
|
||||
sourceDirectory = bundleCollectDir
|
||||
targetDirectory = bundleTransformedDir
|
||||
}
|
||||
|
||||
tasks.processTestResources.dependsOn tasks.jakartafyTemplates
|
||||
|
||||
tasks.test {
|
||||
ext {
|
||||
combinedDirs = project.files( tasks.jakartafyTests.targetDirectory ) + project.files( tasks.jakartafyTemplates.targetDirectory )
|
||||
}
|
||||
|
||||
testClassesDirs += combinedDirs
|
||||
classpath += combinedDirs
|
||||
testClassesDirs += project.files( bundleTransformedDir )
|
||||
classpath += project.files( bundleTransformedDir )
|
||||
|
||||
systemProperty 'file.encoding', 'utf-8'
|
||||
|
||||
|
@ -235,15 +231,4 @@ tasks.test {
|
|||
excludeTestsMatching project.property( 'excludeTests' ).toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task testJar(type: Jar, dependsOn: testClasses) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveClassifier.set( 'test' )
|
||||
from tasks.jakartafyTests.targetDirectory
|
||||
from tasks.jakartafyTemplates.targetDirectory
|
||||
}
|
||||
|
||||
artifacts {
|
||||
tests tasks.testJar
|
||||
}
|
||||
}
|
|
@ -1,6 +1,3 @@
|
|||
import org.hibernate.orm.jakarta.JakartaDirectoryTransformation
|
||||
import org.hibernate.orm.jakarta.JakartaJarTransformation
|
||||
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -10,7 +7,7 @@ import org.hibernate.orm.jakarta.JakartaJarTransformation
|
|||
|
||||
description = 'Hibernate\'s entity version (audit/history) support Jakarta edition'
|
||||
|
||||
apply from: rootProject.file( 'gradle/jakarta-java-module.gradle' )
|
||||
apply from: rootProject.file( 'gradle/published-jakarta-java-module.gradle' )
|
||||
|
||||
evaluationDependsOn( ':hibernate-envers' )
|
||||
evaluationDependsOn( ':hibernate-transaction-client' )
|
||||
|
@ -30,92 +27,92 @@ dependencies {
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// main jar
|
||||
|
||||
tasks.jar {
|
||||
enabled false
|
||||
}
|
||||
|
||||
task jakartafyJar( type: JakartaJarTransformation ) {
|
||||
sourceJar = project(':hibernate-envers').tasks.jar.archiveFile
|
||||
targetJar = tasks.jar.archiveFile
|
||||
}
|
||||
|
||||
tasks.jar.dependsOn project(':hibernate-envers').tasks.jar
|
||||
tasks.jar.finalizedBy tasks.jakartafyJar
|
||||
tasks.jakartafyJar.dependsOn tasks.jar
|
||||
tasks.jakartafyJar.mustRunAfter tasks.jar
|
||||
//tasks.jar {
|
||||
// enabled false
|
||||
//}
|
||||
//
|
||||
//task jakartafyJar( type: JakartaJarTransformation ) {
|
||||
// sourceJar = project(':hibernate-envers').tasks.jar.archiveFile
|
||||
// targetJar = tasks.jar.archiveFile
|
||||
//}
|
||||
//
|
||||
//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
|
||||
//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
|
||||
|
||||
//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
|
||||
//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
|
||||
|
@ -135,12 +132,12 @@ tasks.test {
|
|||
|
||||
tasks.test.dependsOn ':hibernate-transaction-client:jar'
|
||||
|
||||
task testJar(type: Jar, dependsOn: testClasses) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveClassifier.set( 'test' )
|
||||
from sourceSets.test.output
|
||||
}
|
||||
|
||||
artifacts {
|
||||
tests tasks.testJar
|
||||
}
|
||||
//task testJar(type: Jar, dependsOn: testClasses) {
|
||||
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
// archiveClassifier.set( 'test' )
|
||||
// from sourceSets.test.output
|
||||
//}
|
||||
//
|
||||
//artifacts {
|
||||
// tests tasks.testJar
|
||||
//}
|
||||
|
|
|
@ -34,6 +34,14 @@ gradlePlugin {
|
|||
id = 'org.hibernate.orm.antlr'
|
||||
implementationClass = 'org.hibernate.orm.antlr.Antlr4Plugin'
|
||||
}
|
||||
jakartaPlugin {
|
||||
id = 'org.hibernate.orm.jakarta'
|
||||
implementationClass = 'org.hibernate.orm.jakarta.JakartaPlugin'
|
||||
}
|
||||
jakartaPublishPlugin {
|
||||
id = 'org.hibernate.orm.jakarta-publish'
|
||||
implementationClass = 'org.hibernate.orm.jakarta.JakartaPublishingPlugin'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,13 @@ 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;
|
||||
|
||||
import static org.hibernate.orm.jakarta.JakartaPlugin.JAKARTA;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -28,6 +29,8 @@ public abstract class JakartaDirectoryTransformation extends DefaultTask {
|
|||
public JakartaDirectoryTransformation(ObjectFactory objectFactory) {
|
||||
sourceDirectory = objectFactory.directoryProperty();
|
||||
targetDirectory = objectFactory.directoryProperty();
|
||||
|
||||
setGroup( JAKARTA );
|
||||
}
|
||||
|
||||
@InputDirectory
|
||||
|
|
|
@ -15,6 +15,8 @@ import org.gradle.api.tasks.InputFile;
|
|||
import org.gradle.api.tasks.OutputFile;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
import static org.hibernate.orm.jakarta.JakartaPlugin.JAKARTA;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -26,6 +28,8 @@ public abstract class JakartaJarTransformation extends DefaultTask {
|
|||
public JakartaJarTransformation(ObjectFactory objectFactory) {
|
||||
sourceJar = objectFactory.fileProperty();
|
||||
targetJar = objectFactory.fileProperty();
|
||||
|
||||
setGroup( JAKARTA );
|
||||
}
|
||||
|
||||
@InputFile
|
||||
|
|
|
@ -0,0 +1,275 @@
|
|||
/*
|
||||
* 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 org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.file.Directory;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.Copy;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.SourceSetContainer;
|
||||
import org.gradle.api.tasks.TaskContainer;
|
||||
import org.gradle.api.tasks.bundling.Jar;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.api.tasks.testing.Test;
|
||||
import org.gradle.language.jvm.tasks.ProcessResources;
|
||||
|
||||
import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME;
|
||||
import static org.gradle.api.tasks.SourceSet.TEST_SOURCE_SET_NAME;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JakartaPlugin implements Plugin<Project> {
|
||||
public static final String JAKARTA = "jakarta";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
// register short-names for the task classes (fake "import")
|
||||
project.getExtensions().getExtraProperties().set( JakartaDirectoryTransformation.class.getSimpleName(), JakartaDirectoryTransformation.class );
|
||||
project.getExtensions().getExtraProperties().set( JakartaJarTransformation.class.getSimpleName(), JakartaJarTransformation.class );
|
||||
|
||||
final Configuration api = project.getConfigurations().create(
|
||||
"api",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( false );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration implementation = project.getConfigurations().create(
|
||||
"implementation",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( false );
|
||||
configuration.extendsFrom( api );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration compileOnly = project.getConfigurations().create(
|
||||
"compileOnly",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( false );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration runtimeOnly = project.getConfigurations().create(
|
||||
"runtimeOnly",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( false );
|
||||
}
|
||||
);
|
||||
|
||||
project.getConfigurations().create(
|
||||
"compileClasspath",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( true );
|
||||
configuration.extendsFrom( compileOnly, implementation );
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
project.getConfigurations().create(
|
||||
"runtimeClasspath",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( true );
|
||||
configuration.extendsFrom( runtimeOnly, implementation );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration testImplementation = project.getConfigurations().create(
|
||||
"testImplementation",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( false );
|
||||
configuration.extendsFrom( implementation );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration testCompileOnly = project.getConfigurations().create(
|
||||
"testCompileOnly",
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( false );
|
||||
configuration.extendsFrom( compileOnly );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration testRuntimeOnly = project.getConfigurations().create(
|
||||
"testRuntimeOnly" ,
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( false );
|
||||
configuration.extendsFrom( runtimeOnly );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration testCompileClasspath = project.getConfigurations().create(
|
||||
"testCompileClasspath" ,
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( true );
|
||||
configuration.extendsFrom( testImplementation, testCompileOnly );
|
||||
}
|
||||
);
|
||||
|
||||
final Configuration testRuntimeClasspath = project.getConfigurations().create(
|
||||
"testRuntimeClasspath" ,
|
||||
(configuration) -> {
|
||||
configuration.setCanBeConsumed( false );
|
||||
configuration.setCanBeResolved( true );
|
||||
configuration.extendsFrom( testImplementation, testRuntimeOnly );
|
||||
}
|
||||
);
|
||||
|
||||
// determine the "source" project
|
||||
final String path = project.getPath();
|
||||
assert path.endsWith( "-jakarta" ) : "Project path did not end with `-jakarta`";
|
||||
final String sourceProjectPath = path.substring( 0, path.length() - 8 );
|
||||
final Project sourceProject = project.getRootProject().project( sourceProjectPath );
|
||||
|
||||
|
||||
// Get tasks from the source project we will need
|
||||
final TaskContainer sourceProjectTasks = sourceProject.getTasks();
|
||||
final SourceSetContainer sourceProjectSourceSets = extractSourceSets( sourceProject );
|
||||
final SourceSet sourceProjectMainSourceSet = sourceProjectSourceSets.getByName( MAIN_SOURCE_SET_NAME );
|
||||
final Jar sourceProjectJarTask = (Jar) sourceProjectTasks.getByName( sourceProjectMainSourceSet.getJarTaskName() );
|
||||
final Jar sourceProjectSourcesJarTask = (Jar) sourceProjectTasks.getByName( sourceProjectMainSourceSet.getSourcesJarTaskName() );
|
||||
final Jar sourceProjectJavadocJarTask = (Jar) sourceProjectTasks.getByName( sourceProjectMainSourceSet.getJavadocJarTaskName() );
|
||||
final SourceSet sourceProjectTestSourceSet = sourceProjectSourceSets.getByName( TEST_SOURCE_SET_NAME );
|
||||
final JavaCompile sourceProjectCompileTestClassesTask = (JavaCompile) sourceProjectTasks.getByName( sourceProjectTestSourceSet.getCompileJavaTaskName() );
|
||||
final ProcessResources sourceProjectProcessTestResourcesTask = (ProcessResources) sourceProjectTasks.getByName( sourceProjectTestSourceSet.getProcessResourcesTaskName() );
|
||||
|
||||
|
||||
// Create the "jakartafication" assemble tasks
|
||||
final TaskContainer tasks = project.getTasks();
|
||||
final Task jakartafyTask = tasks.create(
|
||||
"jakartafy",
|
||||
(task) -> {
|
||||
task.setDescription( "Performs all of the Jakarta transformations" );
|
||||
task.setGroup( JAKARTA );
|
||||
}
|
||||
);
|
||||
|
||||
tasks.create(
|
||||
"jakartafyJar",
|
||||
JakartaJarTransformation.class,
|
||||
(transformation) -> {
|
||||
transformation.dependsOn( sourceProjectJarTask );
|
||||
transformation.setDescription( "Transforms the source project's main jar" );
|
||||
transformation.setGroup( JAKARTA );
|
||||
transformation.getSourceJar().convention( sourceProjectJarTask.getArchiveFile() );
|
||||
transformation.getTargetJar().convention(
|
||||
project.getLayout()
|
||||
.getBuildDirectory()
|
||||
.file( relativeArchiveFileName( project, null ) )
|
||||
);
|
||||
jakartafyTask.dependsOn( transformation );
|
||||
}
|
||||
);
|
||||
|
||||
tasks.create(
|
||||
"jakartafySourcesJar",
|
||||
JakartaJarTransformation.class,
|
||||
(transformation) -> {
|
||||
transformation.dependsOn( sourceProjectSourcesJarTask );
|
||||
transformation.setDescription( "Transforms the source project's sources jar" );
|
||||
transformation.setGroup( JAKARTA );
|
||||
transformation.getSourceJar().convention( sourceProjectSourcesJarTask.getArchiveFile() );
|
||||
transformation.getTargetJar().convention(
|
||||
project.getLayout()
|
||||
.getBuildDirectory()
|
||||
.file( relativeArchiveFileName( project, "sources" ) )
|
||||
);
|
||||
jakartafyTask.dependsOn( transformation );
|
||||
}
|
||||
);
|
||||
|
||||
tasks.create(
|
||||
"jakartafyJavadocJar",
|
||||
JakartaJarTransformation.class,
|
||||
(transformation) -> {
|
||||
transformation.dependsOn( sourceProjectJavadocJarTask );
|
||||
transformation.setDescription( "Transforms the source project's javadoc jar" );
|
||||
transformation.setGroup( JAKARTA );
|
||||
transformation.getSourceJar().convention( sourceProjectJavadocJarTask.getArchiveFile() );
|
||||
transformation.getTargetJar().convention(
|
||||
project.getLayout()
|
||||
.getBuildDirectory()
|
||||
.file( relativeArchiveFileName( project, "javadoc" ) )
|
||||
);
|
||||
jakartafyTask.dependsOn( transformation );
|
||||
}
|
||||
);
|
||||
|
||||
final Provider<Directory> testCollectDir = project.getLayout().getBuildDirectory().dir( "jakarta/collect/tests" );
|
||||
final Provider<Directory> testTransformedDir = project.getLayout().getBuildDirectory().dir( "jakarta/transformed/tests" );
|
||||
|
||||
final Copy collectTests = tasks.create(
|
||||
"collectTests",
|
||||
Copy.class,
|
||||
(task) -> {
|
||||
task.dependsOn( sourceProjectCompileTestClassesTask, sourceProjectProcessTestResourcesTask );
|
||||
task.setDescription( "Collects all needed test classes and resources into a single directory for transformation" );
|
||||
task.setGroup( JAKARTA );
|
||||
task.from( sourceProjectTestSourceSet.getOutput() );
|
||||
task.into( testCollectDir );
|
||||
}
|
||||
);
|
||||
|
||||
final JakartaDirectoryTransformation jakartafyTests = tasks.create(
|
||||
"jakartafyTests",
|
||||
JakartaDirectoryTransformation.class,
|
||||
(task) -> {
|
||||
task.dependsOn( collectTests );
|
||||
task.setDescription( "Jakartafies the tests in preparation for execution" );
|
||||
task.setGroup( JAKARTA );
|
||||
task.getSourceDirectory().convention( testCollectDir );
|
||||
task.getTargetDirectory().convention( testTransformedDir );
|
||||
}
|
||||
);
|
||||
|
||||
tasks.create(
|
||||
"test",
|
||||
Test.class,
|
||||
(task) -> {
|
||||
task.dependsOn( jakartafyTests );
|
||||
task.setDescription( "Performs the jakartafied tests against the jakartafied artifact" );
|
||||
task.setGroup( JAKARTA );
|
||||
|
||||
final ConfigurableFileCollection transformedTests = project.files( testTransformedDir );
|
||||
task.setTestClassesDirs( transformedTests );
|
||||
task.setClasspath( transformedTests.plus( testRuntimeClasspath ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static String relativeArchiveFileName(Project project, String classifier) {
|
||||
final StringBuilder nameBuilder = new StringBuilder( "lib/" );
|
||||
nameBuilder.append( project.getName() );
|
||||
nameBuilder.append( "-" ).append( project.getVersion() );
|
||||
if ( classifier != null ) {
|
||||
nameBuilder.append( "-" ).append( classifier );
|
||||
}
|
||||
return nameBuilder.append( ".jar" ).toString();
|
||||
}
|
||||
|
||||
public static SourceSetContainer extractSourceSets(Project project) {
|
||||
final JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin( JavaPluginConvention.class );
|
||||
assert javaPluginConvention != null;
|
||||
return javaPluginConvention.getSourceSets();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* 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.util.function.Consumer;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.attributes.AttributeContainer;
|
||||
import org.gradle.api.attributes.Bundling;
|
||||
import org.gradle.api.attributes.Category;
|
||||
import org.gradle.api.attributes.DocsType;
|
||||
import org.gradle.api.attributes.LibraryElements;
|
||||
import org.gradle.api.attributes.Usage;
|
||||
import org.gradle.api.component.AdhocComponentWithVariants;
|
||||
import org.gradle.api.component.SoftwareComponentFactory;
|
||||
import org.gradle.api.model.ObjectFactory;
|
||||
import org.gradle.api.tasks.TaskContainer;
|
||||
import org.gradle.api.tasks.TaskProvider;
|
||||
import org.gradle.api.tasks.testing.Test;
|
||||
|
||||
/**
|
||||
* Models a publishable Jakartafied project
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JakartaPublishingPlugin implements Plugin<Project> {
|
||||
public static final String MAIN_CONFIG_NAME = "jakartaElements";
|
||||
public static final String MAIN_JAR_TASK_NAME = "jakartafyJar";
|
||||
|
||||
public static final String SOURCES_CONFIG_NAME = "jakartaSourcesElements";
|
||||
public static final String SOURCES_JAR_TASK_NAME = "jakartafySourcesJar";
|
||||
|
||||
public static final String JAVADOC_CONFIG_NAME = "jakartaJavadocElements";
|
||||
public static final String JAVADOC_JAR_TASK_NAME = "jakartafyJavadocJar";
|
||||
|
||||
private final SoftwareComponentFactory softwareComponentFactory;
|
||||
|
||||
@Inject
|
||||
public JakartaPublishingPlugin(SoftwareComponentFactory softwareComponentFactory) {
|
||||
this.softwareComponentFactory = softwareComponentFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPlugins().apply( JakartaPlugin.class );
|
||||
|
||||
final AdhocComponentWithVariants jakartaComponent = softwareComponentFactory.adhoc( "jakarta" );
|
||||
project.getComponents().add( jakartaComponent );
|
||||
|
||||
addMainVariant( jakartaComponent, project );
|
||||
addSourcesVariant( jakartaComponent, project );
|
||||
addJavadocVariant( jakartaComponent, project );
|
||||
}
|
||||
|
||||
private void addMainVariant(
|
||||
AdhocComponentWithVariants jakartaComponent,
|
||||
Project project) {
|
||||
final ObjectFactory objectFactory = project.getObjects();
|
||||
final Task jakartafyJar = project.getTasks().getByName( "jakartafyJar" );
|
||||
|
||||
addVariant(
|
||||
MAIN_CONFIG_NAME,
|
||||
MAIN_JAR_TASK_NAME,
|
||||
null,
|
||||
jakartaComponent,
|
||||
jakartafyJar,
|
||||
(attributes) -> {
|
||||
attributes.attribute(
|
||||
Usage.USAGE_ATTRIBUTE,
|
||||
objectFactory.named( Usage.class, Usage.JAVA_RUNTIME )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
Category.CATEGORY_ATTRIBUTE,
|
||||
objectFactory.named( Category.class, Category.LIBRARY )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
Bundling.BUNDLING_ATTRIBUTE,
|
||||
objectFactory.named( Bundling.class, Bundling.EXTERNAL )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
|
||||
objectFactory.named( LibraryElements.class, LibraryElements.CLASSES_AND_RESOURCES )
|
||||
);
|
||||
},
|
||||
project
|
||||
);
|
||||
}
|
||||
|
||||
private void addSourcesVariant(AdhocComponentWithVariants jakartaComponent, Project project) {
|
||||
final ObjectFactory objectFactory = project.getObjects();
|
||||
final Task jakartafyJar = project.getTasks().getByName( "jakartafySourcesJar" );
|
||||
|
||||
addVariant(
|
||||
SOURCES_CONFIG_NAME,
|
||||
SOURCES_JAR_TASK_NAME,
|
||||
"sources",
|
||||
jakartaComponent,
|
||||
jakartafyJar,
|
||||
(attributes) -> {
|
||||
attributes.attribute(
|
||||
Usage.USAGE_ATTRIBUTE,
|
||||
objectFactory.named( Usage.class, Usage.JAVA_RUNTIME )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
Bundling.BUNDLING_ATTRIBUTE,
|
||||
objectFactory.named( Bundling.class, Bundling.EXTERNAL )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
Category.CATEGORY_ATTRIBUTE,
|
||||
objectFactory.named( Category.class, Category.DOCUMENTATION )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
DocsType.DOCS_TYPE_ATTRIBUTE,
|
||||
objectFactory.named( DocsType.class, DocsType.SOURCES )
|
||||
);
|
||||
},
|
||||
project
|
||||
);
|
||||
}
|
||||
|
||||
private void addJavadocVariant(AdhocComponentWithVariants jakartaComponent, Project project) {
|
||||
final ObjectFactory objectFactory = project.getObjects();
|
||||
final Task jakartafyJar = project.getTasks().getByName( "jakartafyJavadocJar" );
|
||||
|
||||
addVariant(
|
||||
JAVADOC_CONFIG_NAME,
|
||||
JAVADOC_JAR_TASK_NAME,
|
||||
"javadoc",
|
||||
jakartaComponent,
|
||||
jakartafyJar,
|
||||
(attributes) -> {
|
||||
attributes.attribute(
|
||||
Usage.USAGE_ATTRIBUTE,
|
||||
objectFactory.named( Usage.class, Usage.JAVA_RUNTIME )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
Bundling.BUNDLING_ATTRIBUTE,
|
||||
objectFactory.named( Bundling.class, Bundling.EXTERNAL )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
Category.CATEGORY_ATTRIBUTE,
|
||||
objectFactory.named( Category.class, Category.DOCUMENTATION )
|
||||
);
|
||||
|
||||
attributes.attribute(
|
||||
DocsType.DOCS_TYPE_ATTRIBUTE,
|
||||
objectFactory.named( DocsType.class, DocsType.JAVADOC )
|
||||
);
|
||||
},
|
||||
project
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private Configuration addVariant(
|
||||
String configName,
|
||||
String jarTaskName,
|
||||
String classifier,
|
||||
AdhocComponentWithVariants jakartaComponent,
|
||||
Task jakartaJarTask,
|
||||
Consumer<AttributeContainer> attributesAdjuster,
|
||||
Project project) {
|
||||
final Configuration variantConfig = project.getConfigurations().create(
|
||||
configName,
|
||||
(publicationConfiguration) -> {
|
||||
publicationConfiguration.setDescription( "Consumable configuration for Jakartafied sources jar" );
|
||||
publicationConfiguration.setCanBeConsumed( true );
|
||||
publicationConfiguration.setCanBeResolved( false );
|
||||
publicationConfiguration.setVisible( false );
|
||||
|
||||
attributesAdjuster.accept( publicationConfiguration.getAttributes() );
|
||||
}
|
||||
);
|
||||
|
||||
jakartaComponent.addVariantsFromConfiguration(
|
||||
variantConfig,
|
||||
(variantDetails) -> variantDetails.mapToMavenScope( "runtime" )
|
||||
);
|
||||
|
||||
final TaskProvider<JakartaJarTransformation> mainJarTask;
|
||||
final TaskContainer tasks = project.getTasks();
|
||||
if ( ! tasks.getNames().contains( jarTaskName ) ) {
|
||||
mainJarTask = tasks.register(
|
||||
jarTaskName,
|
||||
JakartaJarTransformation.class,
|
||||
|
||||
(jakartaficationTask) -> {
|
||||
jakartaficationTask.setDescription( "Produces the Jakartafied main jar for `" + project.getPath() + "`" );
|
||||
}
|
||||
);
|
||||
if ( tasks.getNames().contains( "assemble" ) ) {
|
||||
tasks.named( "assemble" ).configure( (assembleTask) -> assembleTask.dependsOn( mainJarTask ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
mainJarTask = (TaskProvider) tasks.named( jarTaskName );
|
||||
}
|
||||
|
||||
variantConfig.getOutgoing().artifact(
|
||||
mainJarTask.get().getTargetJar(),
|
||||
(artifact) -> {
|
||||
artifact.setClassifier( classifier );
|
||||
artifact.setExtension( "jar" );
|
||||
artifact.builtBy( jakartaJarTask );
|
||||
}
|
||||
);
|
||||
|
||||
return variantConfig;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.Project;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.artifacts.ProjectDependency;
|
||||
|
||||
/**
|
||||
* Gradle DSL extension for configuring the Jakartafying transformations
|
||||
* needed for a project. Mainly used to trigger different conventions depending
|
||||
* on whether the "source" is a local project or an external module
|
||||
*
|
||||
* NOTE : abstract to allow Gradle to "weave in" behavior (like being an extension container, etc)
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class JakartaSpec {
|
||||
public static final String REGISTRATION_NAME = "jakarta";
|
||||
|
||||
private final Project jakartaProject;
|
||||
|
||||
private Dependency sourceDependency;
|
||||
|
||||
@Inject
|
||||
public JakartaSpec(Project jakartaProject) {
|
||||
// `jakartaProject` is the project where this plugin gets applied - the `-jakarta` one
|
||||
this.jakartaProject = jakartaProject;
|
||||
}
|
||||
|
||||
public void source(Object dependencyNotation) {
|
||||
if ( sourceDependency != null ) {
|
||||
throw new IllegalStateException( "Source Dependency already specified" );
|
||||
}
|
||||
|
||||
sourceDependency = jakartaProject.getDependencies().create( dependencyNotation );
|
||||
}
|
||||
|
||||
public Dependency getSourceDependency() {
|
||||
return sourceDependency;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,3 @@
|
|||
import org.hibernate.orm.jakarta.JakartaDirectoryTransformation
|
||||
import org.hibernate.orm.jakarta.JakartaJarTransformation
|
||||
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -11,7 +8,7 @@ import org.hibernate.orm.jakarta.JakartaJarTransformation
|
|||
description = 'Support for testing Hibernate ORM Jakarta functionality'
|
||||
|
||||
|
||||
apply from: rootProject.file( 'gradle/jakarta-java-module.gradle' )
|
||||
apply from: rootProject.file( 'gradle/published-jakarta-java-module.gradle' )
|
||||
|
||||
evaluationDependsOn( ':hibernate-testing' )
|
||||
|
||||
|
@ -48,115 +45,115 @@ dependencies {
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// main jar
|
||||
|
||||
tasks.jar {
|
||||
enabled false
|
||||
}
|
||||
|
||||
task jakartafyJar( type: JakartaJarTransformation ) {
|
||||
sourceJar = project(':hibernate-testing').tasks.jar.archiveFile
|
||||
targetJar = tasks.jar.archiveFile
|
||||
}
|
||||
|
||||
tasks.jar.dependsOn project(':hibernate-testing').tasks.jar
|
||||
tasks.jar.finalizedBy tasks.jakartafyJar
|
||||
tasks.jakartafyJar.dependsOn tasks.jar
|
||||
tasks.jakartafyJar.mustRunAfter tasks.jar
|
||||
|
||||
//tasks.jar {
|
||||
// enabled false
|
||||
//}
|
||||
//
|
||||
//task jakartafyJar( type: JakartaJarTransformation ) {
|
||||
// sourceJar = project(':hibernate-testing').tasks.jar.archiveFile
|
||||
// targetJar = tasks.jar.archiveFile
|
||||
//}
|
||||
//
|
||||
//tasks.jar.dependsOn project(':hibernate-testing').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-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
|
||||
//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
|
||||
|
||||
//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
|
||||
}
|
||||
|
||||
//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
|
||||
//}
|
||||
//
|
||||
|
|
|
@ -79,6 +79,10 @@ pluginBundle {
|
|||
}
|
||||
}
|
||||
|
||||
task publish {
|
||||
dependsOn tasks.publishPlugins
|
||||
}
|
||||
|
||||
processResources {
|
||||
filter( ReplaceTokens, tokens: [ 'hibernateVersion': getVersion() ] )
|
||||
}
|
||||
|
@ -110,6 +114,14 @@ task release {
|
|||
dependsOn tasks.publishPlugins
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if ( project.ormVersion.isSnapshot ) {
|
||||
release.enabled false
|
||||
publish.enabled false
|
||||
publishPlugins.enabled false
|
||||
}
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady { tg ->
|
||||
if ( tg.hasTask( project.tasks.publishPlugins ) ) {
|
||||
if ( credentials.hibernatePluginPortalUsername == null ) {
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
description = 'Annotation Processor to generate JPA 3 static metamodel classes'
|
||||
|
||||
apply from: rootProject.file( 'gradle/jakarta-java-module.gradle' )
|
||||
evaluationDependsOn( ':hibernate-jpamodelgen' )
|
||||
|
||||
apply from: rootProject.file( 'gradle/published-jakarta-java-module.gradle' )
|
||||
|
||||
configurations {
|
||||
jakartaeeTransformJars
|
||||
|
@ -27,42 +29,54 @@ dependencies {
|
|||
testImplementation fileTree(dir: 'libs', include: '*.jar')
|
||||
}
|
||||
|
||||
jar {
|
||||
mustRunAfter project(':hibernate-jpamodelgen').tasks.jar
|
||||
dependsOn project(':hibernate-jpamodelgen').tasks.jar
|
||||
def baseDir = project(':hibernate-jpamodelgen').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-jpamodelgen', 'hibernate-jpamodelgen-jakarta' )
|
||||
println 'Default jakarta final bundle jar name [ ' + finalBundleJarName + ' ]'
|
||||
//task jakartafyJar( type: JakartaJarTransformation ) {
|
||||
// dependsOn project(':hibernate-jpamodelgen').tasks.jar
|
||||
// sourceJar = project(':hibernate-jpamodelgen').tasks.jar.archiveFile
|
||||
// targetJar = tasks.jar.archiveFile
|
||||
//}
|
||||
//
|
||||
//tasks.jar {
|
||||
// enabled false
|
||||
// dependsOn tasks.jakartafyJar
|
||||
//}
|
||||
|
||||
def transformerArgs = [
|
||||
sourceJarPath, finalBundleJarName,
|
||||
'-q', // quiet output
|
||||
'-tr', new File(getProjectDir().getParentFile().getParentFile(), 'rules/jakarta-renames.properties').path,
|
||||
'-tv', new File(getProjectDir().getParentFile().getParentFile(), 'rules/jakarta-versions.properties').path,
|
||||
'-td', new File(getProjectDir().getParentFile().getParentFile(), 'rules/jakarta-direct-modelgen.properties').path,
|
||||
]
|
||||
|
||||
println 'Transformer options:'
|
||||
transformerArgs.each {
|
||||
println ' [ ' + it + ' ]'
|
||||
}
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// javadoc jar
|
||||
|
||||
javaexec {
|
||||
classpath configurations.jakartaeeTransformJars
|
||||
main = 'org.eclipse.transformer.jakarta.JakartaTransformer'
|
||||
args = transformerArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//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
|
||||
|
|
Loading…
Reference in New Issue