Skip to content

Commit

Permalink
HHH-13946 Create Jakarta artifacts for hibernate-core, hibernate-enve…
Browse files Browse the repository at this point in the history
…rs, hibernate-jpamodelgen and hibernate-testing
  • Loading branch information
beikov committed Apr 30, 2021
1 parent eb8b862 commit ff9e9ee
Show file tree
Hide file tree
Showing 43 changed files with 1,224 additions and 9 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ext {
ormVersion = new HibernateVersion( project.releaseVersion, project )
}
jpaVersion = new JpaVersion('2.2')
jakartaJpaVersion = new JpaVersion('3.0.0')
}

// The Gradle Nexus Publish Plugin must be applied to the root project and requires group and version
Expand Down
28 changes: 27 additions & 1 deletion gradle/libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ ext {
hibernateValidatorVersion = '6.1.6.Final'
validationApiVersion = '2.0.1.Final'
elVersion = '3.0.1-b09'
hibernateValidatorJakartaVersion = '7.0.1.Final'

cdiVersion = '2.0'
weldVersion = '3.1.5.Final'
jakartaWeldVersion = '4.0.1.SP1'

javassistVersion = '3.27.0-GA'
byteBuddyVersion = '1.10.21'
Expand All @@ -40,6 +42,7 @@ ext {
// We can't upgrade JAXB in Karaf (yet), but fortunately everything works fine with the version built in Karaf
jaxbApiVersionOsgiRange = "[2.2,3)"
jaxbRuntimeVersion = '2.3.1'
jakartaJaxbRuntimeVersion = '3.0.0'

//GraalVM
graalvmVersion = '19.3.1'
Expand Down Expand Up @@ -76,6 +79,18 @@ ext {
// required by JAXB from JDK 9 as it is not available anymore in JDK 9
activation: 'javax.activation:javax.activation-api:1.2.0',

// jakarta
jakarta_jpa: "jakarta.persistence:jakarta.persistence-api:${project.jakartaJpaVersion}",
jakarta_jta: 'jakarta.transaction:jakarta.transaction-api:2.0.0',
jakarta_validation: 'jakarta.validation:jakarta.validation-api:3.0.0',
jakarta_jacc: 'jakarta.authorization:jakarta.authorization-api:2.0.0',
jakarta_interceptor: 'jakarta.interceptor:jakarta.interceptor-api:2.0.0',
jakarta_activation: 'jakarta.activation:jakarta.activation-api:2.0.1',
jakarta_resource: 'jakarta.resource:jakarta.resource-api:2.0.0',
jakarta_jaxb_api: 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.0',
jakarta_jaxb_runtime: "org.glassfish.jaxb:jaxb-runtime:${jakartaJaxbRuntimeVersion}",
jakarta_cdi: 'jakarta.enterprise:jakarta.enterprise.cdi-api:3.0.0',

// logging
logging: 'org.jboss.logging:jboss-logging:3.4.1.Final',
logging_annotations: 'org.jboss.logging:jboss-logging-annotations:2.1.0.Final',
Expand Down Expand Up @@ -126,7 +141,11 @@ ext {
jodaTime: "joda-time:joda-time:${jodaTimeVersion}",

informix: 'com.ibm.informix:jdbc:4.10.12',
jboss_jta: "org.jboss.jbossts:jbossjta:4.16.4.Final",
jboss_jta: "org.jboss.narayana.jta:narayana-jta:5.11.1.Final",
jboss_tx_spi: "org.jboss:jboss-transaction-spi:7.6.0.Final",
// todo (jakarta): update the version when it is released
jboss_jta_jakarta: "org.jboss.narayana.jta:narayana-jta-jakarta:5.11.2.Final",
jboss_tx_spi_jakarta: "org.jboss:jboss-transaction-spi-jakarta:7.6.1.Final",
xapool: "com.experlog:xapool:1.5.0",
mockito: 'org.mockito:mockito-core:2.19.1',
mockito_inline: 'org.mockito:mockito-inline:2.19.1',
Expand All @@ -135,6 +154,10 @@ ext {
// EL required by Hibernate Validator at test runtime
expression_language: "org.glassfish:javax.el:${elVersion}",

jakarta_validator:"org.hibernate.validator:hibernate-validator:${hibernateValidatorJakartaVersion}",
// EL required by Hibernate Validator at test runtime
jakarta_el: 'org.glassfish:jakarta.el:4.0.1',

c3p0: "com.mchange:c3p0:0.9.5.5",
ehcache: "net.sf.ehcache:ehcache:2.10.6",
ehcache3: "org.ehcache:ehcache:3.6.1",
Expand All @@ -151,6 +174,7 @@ ext {

cdi: "javax.enterprise:cdi-api:${cdiVersion}",
weld: "org.jboss.weld.se:weld-se-shaded:${weldVersion}",
jakarta_weld: "org.jboss.weld.se:weld-se-shaded:${jakartaWeldVersion}",

assertj: "org.assertj:assertj-core:${assertjVersion}",

Expand All @@ -163,6 +187,8 @@ ext {

jboss_vfs: "org.jboss:jboss-vfs:3.2.11.Final",
wildfly_transaction_client : 'org.wildfly.transaction:wildfly-transaction-client:1.1.7.Final',
// todo (jakarta): update the version when it is released
wildfly_transaction_client_jakarta : 'org.wildfly.transaction:wildfly-transaction-client-jakarta:1.2.0.Final-SNAPSHOT',

jboss_ejb_spec_jar : 'org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Final',
jboss_annotation_spec_jar : 'org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:1.0.0.Final',
Expand Down
182 changes: 182 additions & 0 deletions hibernate-core-jakarta/hibernate-core-jakarta.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/*
* 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.apache.tools.ant.filters.ReplaceTokens

description = 'Hibernate O/RM implementation of the Jakarta Persistence specification'

apply from: rootProject.file( 'gradle/published-java-module.gradle' )

configurations {
tests {
description = 'Configuration for the produced test jar'
}
jakartaeeTransformJars
}

dependencies {
compile( libraries.jakarta_jpa )
// This can now be made provided
compile( libraries.javassist )
// Could be made optional?
compile( libraries.byteBuddy )
compile( libraries.antlr )
compile( libraries.jakarta_jta )
compile( libraries.jandex )
compile( libraries.classmate )
compile( libraries.jakarta_activation )

provided( libraries.jakarta_jacc )
provided( libraries.jakarta_validation )
provided( libraries.ant )
provided( libraries.jakarta_cdi )

compile( libraries.dom4j )
compile( libraries.commons_annotations )

compile( libraries.jakarta_jaxb_api )
compile( 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'
testCompile( project(':hibernate-testing-jakarta') )
testCompile fileTree(dir: 'libs', include: '*.jar')

testCompile( libraries.shrinkwrap_api )
testCompile( libraries.shrinkwrap )
testCompile( libraries.jakarta_jacc )
testCompile( libraries.jakarta_validation )
testCompile( libraries.jandex )
testCompile( libraries.classmate )
testCompile( libraries.mockito )
testCompile( libraries.mockito_inline )
testCompile( libraries.jodaTime )
testCompile( libraries.assertj )

testCompile( libraries.jakarta_cdi )

testCompile( libraries.jakarta_validator ) {
// for test runtime
transitive = true
}

// for testing stored procedure support
testCompile( libraries.derby )

testRuntime( "org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Final" )
testRuntime( libraries.jakarta_el )
testRuntime( 'jaxen:jaxen:1.1' )
testRuntime( libraries.javassist )
testRuntime( libraries.byteBuddy )
testRuntime( libraries.jakarta_weld )
testRuntime( libraries.atomikos )
testRuntime( libraries.atomikos_jta )
// todo (jakarta): replace this when the jakarta artifact is released
testRuntime( project(':hibernate-transaction-client') )
// testRuntime( libraries.wildfly_transaction_client_jakarta )

testCompile libraries.shrinkwrap_descriptors_api_javaee
testCompile libraries.shrinkwrap_descriptors_impl_javaee

testCompile libraries.jboss_ejb_spec_jar
testCompile libraries.jboss_annotation_spec_jar
}

jar {
mustRunAfter project(':hibernate-core').tasks.jar
mustRunAfter project(':hibernate-core').tasks.testJar
dependsOn project(':hibernate-core').tasks.jar
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 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
filter( ReplaceTokens, tokens: ext.bundleTokens)
doFirst {
ext.bundlesTargetDir.mkdirs()
}
}

processTestResources.dependsOn copyBundleResources

artifacts {
tests new File(project.buildDir, "libs/hibernate-core-jakarta-${project.version}-test.jar")
}

test {
fileTree(project.buildDir).matching { include 'libs/*-test.jar' }.each {
def outputDir = file("${buildDir}/unpacked/" + it.name)
testClassesDirs += files(outputDir)
classpath += files(outputDir)
}
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'] )
}
}
6 changes: 4 additions & 2 deletions hibernate-core/hibernate-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sourceSets {
// resources inherently exclude sources
test {
resources {
setSrcDirs( ['src/test/java','src/test/resources'] )
setSrcDirs( ['src/test/java','src/test/resources','src/test/bundles'] )
}
}

Expand Down Expand Up @@ -145,6 +145,7 @@ jar {
// For JPA, we don't want to target the automatically generated range, but a specific version
"javax.persistence;version=\"${project.jpaVersion.osgiName}\"",
// optionals
'jakarta.persistence.spi;resolution:=optional',
'javax.management;resolution:=optional',
'javax.naming.event;resolution:=optional',
'javax.naming.spi;resolution:=optional',
Expand Down Expand Up @@ -218,7 +219,7 @@ task copyBundleResources (type: Copy) {
ext.bundleTokens['buildDirName'] = buildDir.absolutePath
}

from file('src/test/bundles')
from file('src/test/bundles/templates')
into ext.bundlesTargetDir
filter( ReplaceTokens, tokens: ext.bundleTokens)

Expand All @@ -229,6 +230,7 @@ task copyBundleResources (type: Copy) {
processTestResources.dependsOn copyBundleResources

task testJar(type: Jar, dependsOn: testClasses) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier.set( 'test' )
from sourceSets.test.output
}
Expand Down
Loading

0 comments on commit ff9e9ee

Please sign in to comment.