From 5f836622269f7db171923104462e9059645874fa Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Sat, 14 Mar 2020 15:25:36 -0400 Subject: [PATCH 01/15] HHH-13889 fix the issue that inline string literal in Criteria is not escaped --- .../expression/LiteralExpression.java | 3 +- .../CriteriaStringInlineLiteralTest.java | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/query/criteria/CriteriaStringInlineLiteralTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/LiteralExpression.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/LiteralExpression.java index 855c842ab5..e7639a1dff 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/LiteralExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/LiteralExpression.java @@ -8,6 +8,7 @@ import java.io.Serializable; +import org.hibernate.internal.util.StringHelper; import org.hibernate.query.criteria.LiteralHandlingMode; import org.hibernate.query.criteria.internal.CriteriaBuilderImpl; import org.hibernate.query.criteria.internal.ParameterRegistry; @@ -118,7 +119,7 @@ private String renderProjection(RenderingContext renderingContext) { } if ( ValueHandlerFactory.isCharacter( literal ) ) { - return '\'' + handler.render( literal ) + '\''; + return renderingContext.getDialect().inlineLiteral( handler.render( literal ) ); } else { return handler.render( literal ); diff --git a/hibernate-core/src/test/java/org/hibernate/query/criteria/CriteriaStringInlineLiteralTest.java b/hibernate-core/src/test/java/org/hibernate/query/criteria/CriteriaStringInlineLiteralTest.java new file mode 100644 index 0000000000..31bda50929 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/query/criteria/CriteriaStringInlineLiteralTest.java @@ -0,0 +1,58 @@ +package org.hibernate.query.criteria; + +import javax.persistence.Entity; +import javax.persistence.EntityManager; +import javax.persistence.Id; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Expression; +import javax.persistence.criteria.Root; + +import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; + +import org.hibernate.testing.TestForIssue; +import org.junit.Test; + +/** + * @author Michiel Haisma + * @author Nathan Xu + */ +@TestForIssue( jiraKey = "HHH-13889" ) +public class CriteriaStringInlineLiteralTest extends BaseEntityManagerFunctionalTestCase { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { Animal.class }; + } + + @Test + public void testCriteriaInlineStringLiteralRendering() { + EntityManager entityManager = getOrCreateEntityManager(); + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery criteriaQuery = cb.createQuery( Animal.class ); + + Root animalRoot = criteriaQuery.from( Animal.class ); + CriteriaBuilder.Case sCase = cb.selectCase(); + Expression caseSelect = + sCase.when( cb.equal( animalRoot.get( "name" ), cb.literal( "kitty" ) ), cb.literal( "Cat" ) ) + .otherwise("escapez'moi" ); + criteriaQuery.multiselect( caseSelect ); + criteriaQuery.where( cb.equal( animalRoot.get( "name" ), "myFavoriteAnimal" ) ); + entityManager.createQuery( criteriaQuery); // would throw exception for unescaped otherwise literal in HHH-13889 + } + + @Entity(name = "Animal") + public static class Animal { + @Id + private Long id; + + private String name; + + public Animal() { + } + + public Animal(String name) { + this.name = name; + } + } +} From 47f02f2e6e200ebfbb30976a7950883de3a108de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 21 Oct 2019 17:37:54 +0200 Subject: [PATCH 02/15] HHH-13685 Enable the "stable publishing" feature to test it before upgrading to Gradle 5 --- settings.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/settings.gradle b/settings.gradle index 6676d2d3f4..84771f3b24 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,8 @@ if ( !JavaVersion.current().java8Compatible ) { throw new GradleException( "Gradle must be run with Java 8" ) } +enableFeaturePreview('STABLE_PUBLISHING') + include 'hibernate-core' include 'hibernate-entitymanager' include 'hibernate-testing' From ae4bc5e55dee8fc0c57f7362aed142284a283754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 21 Oct 2019 18:29:06 +0200 Subject: [PATCH 03/15] HHH-13685 Remove uses of deprecated classesDir --- gradle/published-java-module.gradle | 4 ++-- hibernate-osgi/hibernate-osgi.gradle | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle/published-java-module.gradle b/gradle/published-java-module.gradle index 03b715baa5..3e1eb5f16d 100644 --- a/gradle/published-java-module.gradle +++ b/gradle/published-java-module.gradle @@ -25,7 +25,7 @@ jar { classesDir = sourceSets.main.groovy.outputDir } else { - classesDir = sourceSets.main.output.classesDir + classesDir = sourceSets.main.java.outputDir } classpath = configurations.runtime @@ -116,7 +116,7 @@ javadoc { doFirst { // ordering problems if we try to do this during config phase :( - classpath += project.sourceSets.main.output + project.sourceSets.main.compileClasspath + project.configurations.provided + classpath += project.sourceSets.main.output.classesDirs + project.sourceSets.main.compileClasspath + project.configurations.provided } } } diff --git a/hibernate-osgi/hibernate-osgi.gradle b/hibernate-osgi/hibernate-osgi.gradle index 613dc564dc..90a0e912f5 100644 --- a/hibernate-osgi/hibernate-osgi.gradle +++ b/hibernate-osgi/hibernate-osgi.gradle @@ -44,8 +44,8 @@ sourceSets { test { // send javac output and resource copying to the same output directory for test // so Pax Exam can more easily find it without explicit TinyBundle hooks - output.classesDir = "${buildDir}/classes/test" - output.resourcesDir = output.classesDir + java.outputDir = file( "${buildDir}/classes/test" ) + output.resourcesDir = java.outputDir } } @@ -218,7 +218,7 @@ task generatePaxExamEnvironmentFile { properties.setProperty( 'org.ops4j.pax.exam.container.karaf.distroUrl', karafDistroFile.toURI().toURL().toExternalForm() ) properties.setProperty( 'org.ops4j.pax.exam.container.karaf.unpackDir', karafUnpackDirectory.absolutePath ) properties.setProperty( 'org.ops4j.pax.exam.container.karaf.version', karafVersion as String ) - properties.setProperty( 'org.ops4j.pax.exam.container.karaf.probe.classesDir', sourceSets.test.output.classesDir.absolutePath ) + properties.setProperty( 'org.ops4j.pax.exam.container.karaf.probe.classesDir', sourceSets.test.java.outputDir.absolutePath ) properties.setProperty( 'org.ops4j.pax.exam.container.karaf.probe.resourcesDir', sourceSets.test.output.resourcesDir.absolutePath ) properties.setProperty( 'org.hibernate.osgi.test.karafFeatureFile', karaf.features.outputFile.absolutePath ) From 6921b02891676552276936e336a8a7f76c1aa490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 21 Oct 2019 18:48:17 +0200 Subject: [PATCH 04/15] HHH-13685 Upgrade to Gradle 5.6.3 --- build.gradle | 3 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- .../hibernate/orm/tooling/gradle/HibernatePluginTest.groovy | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 5d7ad8a807..a2107e6967 100644 --- a/build.gradle +++ b/build.gradle @@ -84,7 +84,8 @@ task ciBuild { wrapper { - gradleVersion = '4.10.3' + // To upgrade the version of gradle used in the wrapper, run: + // ./gradlew wrapper --gradle-version NEW_VERSION distributionType = Wrapper.DistributionType.ALL } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae45383b6d..3a54a3332e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/tooling/hibernate-gradle-plugin/src/test/groovy/org/hibernate/orm/tooling/gradle/HibernatePluginTest.groovy b/tooling/hibernate-gradle-plugin/src/test/groovy/org/hibernate/orm/tooling/gradle/HibernatePluginTest.groovy index f2e57885c5..845e4a681b 100644 --- a/tooling/hibernate-gradle-plugin/src/test/groovy/org/hibernate/orm/tooling/gradle/HibernatePluginTest.groovy +++ b/tooling/hibernate-gradle-plugin/src/test/groovy/org/hibernate/orm/tooling/gradle/HibernatePluginTest.groovy @@ -82,6 +82,8 @@ class HibernatePluginTest { ) } - compileTestTask.execute() + // TODO find how to do this in Gradle 5 + // the class-level javadoc says it's not possible, and it was there in Gradle 4.x... + //compileTestTask.execute() } } From 08132916bb15b80ad086f6fa0bbfdf7351ed6c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 21 Oct 2019 18:49:41 +0200 Subject: [PATCH 05/15] HHH-13685 Upgrade to hibernate-matrix-testing 3.0.0.Final --- build.gradle | 2 +- buildSrc/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a2107e6967..943912eeb1 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { } dependencies { classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' - classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:2.0.0.Final' + classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:3.0.0.Final' classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' classpath 'org.hibernate.build.gradle:gradle-xjc-plugin:1.0.2.Final' classpath 'gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.1.1' diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 284b69b6c1..b83a5f312c 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -18,5 +18,5 @@ dependencies { compile localGroovy() compile 'org.hibernate.build.gradle:gradle-animalSniffer-plugin:1.0.1.Final' - compile 'org.hibernate.build.gradle:hibernate-matrix-testing:2.0.0.Final' + compile 'org.hibernate.build.gradle:hibernate-matrix-testing:3.0.0.Final' } From 30ad825775b12a33d1452016d4980ab34596aa64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 22 Oct 2019 19:03:58 +0200 Subject: [PATCH 06/15] HHH-13685 Upgrade to gradle-xjc-plugin 2.0.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 943912eeb1..55bf3d0b16 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,6 @@ buildscript { classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:3.0.0.Final' classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' - classpath 'org.hibernate.build.gradle:gradle-xjc-plugin:1.0.2.Final' classpath 'gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.1.1' classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' @@ -25,6 +24,7 @@ buildscript { plugins { id 'com.gradle.build-scan' version '1.16' id 'me.champeau.buildscan-recipes' version '0.2.3' + id 'org.hibernate.build.xjc' version '2.0.1' apply false } allprojects { From e14d20d82989692a7b2ed928d615da2ada670a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 21 Oct 2019 18:53:36 +0200 Subject: [PATCH 07/15] HHH-13685 Upgrade to build-scan plugin 2.4.2 --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 55bf3d0b16..f9f618ba34 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ buildscript { } plugins { - id 'com.gradle.build-scan' version '1.16' + id 'com.gradle.build-scan' version '2.4.2' id 'me.champeau.buildscan-recipes' version '0.2.3' id 'org.hibernate.build.xjc' version '2.0.1' apply false } @@ -91,8 +91,8 @@ wrapper { buildScan { - licenseAgreementUrl = 'https://gradle.com/terms-of-service' - licenseAgree = 'yes' + termsOfServiceUrl = 'https://gradle.com/terms-of-service' + termsOfServiceAgree = 'yes' } buildScanRecipes { From 1d98edc40266bb3a4116bf5cdf4f57b9c03d6932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 22 Oct 2019 16:43:44 +0200 Subject: [PATCH 08/15] HHH-13685 Remove the deprecated "stable publishing" feature flag It's the default behavior in Gradle 5. --- settings.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/settings.gradle b/settings.gradle index 84771f3b24..6676d2d3f4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,8 +8,6 @@ if ( !JavaVersion.current().java8Compatible ) { throw new GradleException( "Gradle must be run with Java 8" ) } -enableFeaturePreview('STABLE_PUBLISHING') - include 'hibernate-core' include 'hibernate-entitymanager' include 'hibernate-testing' From cee0fce043ab397fc36885a57732b2f5a6d581be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 23 Oct 2019 09:58:09 +0200 Subject: [PATCH 09/15] HHH-13685 Replace uses of deprecated classifier property in Jar tasks with archiveClassifier --- gradle/published-java-module.gradle | 4 ++-- hibernate-core/hibernate-core.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/published-java-module.gradle b/gradle/published-java-module.gradle index 3e1eb5f16d..7d8e3b4eb2 100644 --- a/gradle/published-java-module.gradle +++ b/gradle/published-java-module.gradle @@ -67,13 +67,13 @@ jar { task sourcesJar(type: Jar) { from project.sourceSets.main.allSource manifest = project.tasks.jar.manifest - classifier = 'sources' + archiveClassifier.set( 'sources' ) } task javadocJar(type: Jar) { from project.tasks.javadoc.outputs manifest = project.tasks.jar.manifest - classifier = 'javadoc' + archiveClassifier.set( 'javadoc' ) } diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index f34338efc6..c8abd8c3d1 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -217,7 +217,7 @@ task copyBundleResources (type: Copy) { processTestResources.dependsOn copyBundleResources task testJar(type: Jar, dependsOn: testClasses) { - classifier = 'test' + archiveClassifier.set( 'test' ) from sourceSets.test.output } From 7be9e625045fa2c64d22e5924525295aad84f9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 22 Oct 2019 17:39:29 +0200 Subject: [PATCH 10/15] HHH-13685 Increase the heap size for Gradle Otherwise I get an OutOfMemoryError... --- gradle.properties | 1 + 1 file changed, 1 insertion(+) create mode 100644 gradle.properties diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000000..6e54285206 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError From 34e498fb3dc5643aab3b4886044cf9858cc6b304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 25 Oct 2019 10:27:28 +0200 Subject: [PATCH 11/15] HHH-13685 Upgrade to maven-repo-auth 3.0.2 --- build.gradle | 2 +- gradle/publishing-repos.gradle | 2 +- hibernate-infinispan/hibernate-infinispan.gradle | 2 +- hibernate-orm-modules/hibernate-orm-modules.gradle | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index f9f618ba34..33759f52b0 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,6 @@ buildscript { mavenCentral() } dependencies { - classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:3.0.0.Final' classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' classpath 'gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.1.1' @@ -25,6 +24,7 @@ plugins { id 'com.gradle.build-scan' version '2.4.2' id 'me.champeau.buildscan-recipes' version '0.2.3' id 'org.hibernate.build.xjc' version '2.0.1' apply false + id 'org.hibernate.build.maven-repo-auth' version '3.0.2' apply false } allprojects { diff --git a/gradle/publishing-repos.gradle b/gradle/publishing-repos.gradle index 7a5031b47b..b3245a10d5 100644 --- a/gradle/publishing-repos.gradle +++ b/gradle/publishing-repos.gradle @@ -9,7 +9,7 @@ apply from: rootProject.file( 'gradle/base-information.gradle' ) apply plugin: 'maven-publish' -apply plugin: 'maven-publish-auth' +apply plugin: 'org.hibernate.build.maven-repo-auth' apply plugin: 'com.jfrog.bintray' diff --git a/hibernate-infinispan/hibernate-infinispan.gradle b/hibernate-infinispan/hibernate-infinispan.gradle index 122450e2b1..4db08089dc 100644 --- a/hibernate-infinispan/hibernate-infinispan.gradle +++ b/hibernate-infinispan/hibernate-infinispan.gradle @@ -9,7 +9,7 @@ apply from: rootProject.file( 'gradle/base-information.gradle' ) apply from: rootProject.file( 'gradle/publishing-repos.gradle' ) apply from: rootProject.file( 'gradle/publishing-pom.gradle' ) apply plugin: 'maven-publish' -apply plugin: 'maven-publish-auth' +apply plugin: 'org.hibernate.build.maven-repo-auth' description = '(deprecated - use org.infinispan:infinispan-hibernate-cache-v53 instead)' diff --git a/hibernate-orm-modules/hibernate-orm-modules.gradle b/hibernate-orm-modules/hibernate-orm-modules.gradle index b4f865936d..7d7cab1082 100644 --- a/hibernate-orm-modules/hibernate-orm-modules.gradle +++ b/hibernate-orm-modules/hibernate-orm-modules.gradle @@ -15,7 +15,7 @@ apply plugin: 'java' apply from: rootProject.file( 'gradle/libraries.gradle' ) apply plugin: 'maven-publish' -apply plugin: 'maven-publish-auth' +apply plugin: 'org.hibernate.build.maven-repo-auth' apply from: rootProject.file( 'gradle/publishing-repos.gradle' ) apply from: rootProject.file( 'gradle/publishing-pom.gradle' ) From ab4d87cfd1301c1f96e6bf212e711694c2f76e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 25 Oct 2019 16:59:15 +0200 Subject: [PATCH 12/15] HHH-13685 Upgrade to gradle-karaf-plugin 0.5.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 33759f52b0..90b95c89e7 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { dependencies { classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:3.0.0.Final' classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' - classpath 'gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.1.1' + classpath 'gradle.plugin.com.github.lburgazzoli:gradle-karaf-plugin:0.5.1' classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'de.thetaphi:forbiddenapis:2.5' From 42f3948ce58677e20a72633ea00483b99c8268a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 31 Mar 2020 18:05:50 +0200 Subject: [PATCH 13/15] HHH-13685 Remove the obsolete FileContentsHolder module in checkstyle configuration See https://github.com/checkstyle/checkstyle/issues/3573 --- shared/config/checkstyle/checkstyle-non-fatal.xml | 3 --- shared/config/checkstyle/checkstyle.xml | 2 -- 2 files changed, 5 deletions(-) diff --git a/shared/config/checkstyle/checkstyle-non-fatal.xml b/shared/config/checkstyle/checkstyle-non-fatal.xml index f8df9f8431..9e8496ebb3 100644 --- a/shared/config/checkstyle/checkstyle-non-fatal.xml +++ b/shared/config/checkstyle/checkstyle-non-fatal.xml @@ -10,9 +10,6 @@ - - - diff --git a/shared/config/checkstyle/checkstyle.xml b/shared/config/checkstyle/checkstyle.xml index 51c9782e19..eafc2734d0 100644 --- a/shared/config/checkstyle/checkstyle.xml +++ b/shared/config/checkstyle/checkstyle.xml @@ -22,8 +22,6 @@ - - From bb93bc839f9c834984e4305c83ee4f73e8830e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Tue, 31 Mar 2020 18:09:12 +0200 Subject: [PATCH 14/15] HHH-13685 Move Suppression*CommentFilter to its new place in checkstyle config See https://stackoverflow.com/a/55266521/6692043 --- .../checkstyle/checkstyle-non-fatal.xml | 37 +++++++++---------- shared/config/checkstyle/checkstyle.xml | 37 +++++++++---------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/shared/config/checkstyle/checkstyle-non-fatal.xml b/shared/config/checkstyle/checkstyle-non-fatal.xml index 9e8496ebb3..dff679e6fd 100644 --- a/shared/config/checkstyle/checkstyle-non-fatal.xml +++ b/shared/config/checkstyle/checkstyle-non-fatal.xml @@ -147,6 +147,24 @@ + + + + + + + + + + + + + @@ -165,23 +183,4 @@ - - - - - - - - - - - - - - diff --git a/shared/config/checkstyle/checkstyle.xml b/shared/config/checkstyle/checkstyle.xml index eafc2734d0..ca5530643e 100644 --- a/shared/config/checkstyle/checkstyle.xml +++ b/shared/config/checkstyle/checkstyle.xml @@ -61,6 +61,24 @@ + + + + + + + + + + + + + - - - - - - - - - - - - From 2f32169249952849e7fc22b7b22ebe9790432973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 23 Oct 2019 10:03:00 +0200 Subject: [PATCH 15/15] HHH-13689 Replace uses of the deprecated osgi plugin with the biz.aQute.bnd plugin https://docs.gradle.org/5.0-milestone-1/release-notes.html#deprecated-osgi-plugin --- build.gradle | 1 + gradle/java-module.gradle | 2 +- gradle/published-java-module.gradle | 111 +++++++++++------- hibernate-core/hibernate-core.gradle | 79 ++++++++----- .../hibernate-entitymanager.gradle | 14 ++- hibernate-envers/hibernate-envers.gradle | 29 +++-- hibernate-java8/hibernate-java8.gradle | 14 ++- hibernate-osgi/hibernate-osgi.gradle | 23 ++-- 8 files changed, 167 insertions(+), 106 deletions(-) diff --git a/build.gradle b/build.gradle index 90b95c89e7..f8832aaa8f 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ buildscript { classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'de.thetaphi:forbiddenapis:2.5' + classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.2.0' } } diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index c5ec219de9..3275dbb548 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -26,7 +26,7 @@ apply from: rootProject.file( 'gradle/libraries.gradle' ) apply from: rootProject.file( 'gradle/databases.gradle' ) apply plugin: 'java' -apply plugin: 'osgi' +apply plugin: 'biz.aQute.bnd.builder' apply plugin: 'checkstyle' apply plugin: 'build-dashboard' diff --git a/gradle/published-java-module.gradle b/gradle/published-java-module.gradle index 7d8e3b4eb2..f98f7a4494 100644 --- a/gradle/published-java-module.gradle +++ b/gradle/published-java-module.gradle @@ -10,69 +10,90 @@ apply from: rootProject.file( 'gradle/java-module.gradle' ) apply from: rootProject.file( 'gradle/publishing-repos.gradle' ) apply from: rootProject.file( 'gradle/publishing-pom.gradle' ) - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Jar jar { - manifest = osgiManifest { - // GRADLE-1411: Even if we override Imports and Exports - // auto-generation with instructions, classesDir and classpath - // need to be here (temporarily). + manifest { + attributes( + // Basic JAR manifest attributes + 'Specification-Title': project.name, + 'Specification-Version': project.version, + 'Specification-Vendor': 'Hibernate.org', + 'Implementation-Title': project.name, + 'Implementation-Version': project.version, + 'Implementation-Vendor': 'Hibernate.org', + 'Implementation-Vendor-Id': 'org.hibernate', + 'Implementation-Url': 'http://hibernate.org/orm', - if ( project.pluginManager.hasPlugin( 'groovy' ) ) { - classesDir = sourceSets.main.groovy.outputDir - } - else { - classesDir = sourceSets.main.java.outputDir - } - classpath = configurations.runtime + // Java 9 module name + 'Automatic-Module-Name': project.java9ModuleName, + // Hibernate-specific JAR manifest attributes + 'Hibernate-VersionFamily': project.ormVersion.family, + 'Hibernate-JpaVersion': project.jpaVersion.name, - // Java 9 module name - instruction 'Automatic-Module-Name', project.java9ModuleName - - // the OSGi metadata - symbolicName project.java9ModuleName - vendor 'Hibernate.org' - description project.description - docURL "http://www.hibernate.org/orm/${project.ormVersion.family}" - - instruction 'Import-Package', - // Temporarily support JTA 1.1 -- Karaf and other frameworks still - // use it. Without this, the plugin generates [1.2,2). - 'javax.transaction;version="[1.1,2)"', - // Tell Gradle OSGi to still dynamically import the other packages. - // IMPORTANT: Do not include the * in the modules' .gradle files. - // If it exists more than once, the manifest will physically contain a *. - '*' - - // Basic JAR manifest metadata - instruction 'Specification-Title', project.name - instruction 'Specification-Version', project.version - instruction 'Specification-Vendor', 'Hibernate.org' - instruction 'Implementation-Title', project.name - instruction 'Implementation-Version', project.version - instruction 'Implementation-Vendor', 'Hibernate.org' - instruction 'Implementation-Vendor-Id', 'org.hibernate' - instruction 'Implementation-Url', 'http://hibernate.org/orm' - - instruction 'Hibernate-VersionFamily', project.ormVersion.family - instruction 'Hibernate-JpaVersion', project.jpaVersion.name + // BND Plugin instructions (for OSGi): + 'Bundle-Name': project.name, + 'Bundle-SymbolicName': project.java9ModuleName, + 'Bundle-Vendor': 'Hibernate.org', + 'Bundle-DocURL': "http://www.hibernate.org/orm/${project.ormVersion.family}", + // This is overridden in some sub-projects + 'Import-Package': [ + // Temporarily support JTA 1.1 -- Karaf and other frameworks still + // use it. Without this, the plugin generates [1.2,2). + 'javax.transaction;version="[1.1,2)"', + // Also import every package referenced in the code + // (note that '*' is resolved at build time to a list of packages) + '*' + ].join( ',' ), + '-exportcontents': "*;version=${project.version}" + ) } } task sourcesJar(type: Jar) { from project.sourceSets.main.allSource - manifest = project.tasks.jar.manifest + manifest { + attributes( + // Basic JAR manifest attributes + 'Specification-Title': project.name, + 'Specification-Version': project.version, + 'Specification-Vendor': 'Hibernate.org', + 'Implementation-Title': project.name, + 'Implementation-Version': project.version, + 'Implementation-Vendor': 'Hibernate.org', + 'Implementation-Vendor-Id': 'org.hibernate', + 'Implementation-Url': 'http://hibernate.org/orm', + + // Hibernate-specific JAR manifest attributes + 'Hibernate-VersionFamily': project.ormVersion.family, + 'Hibernate-JpaVersion': project.jpaVersion.name + ) + } archiveClassifier.set( 'sources' ) } task javadocJar(type: Jar) { from project.tasks.javadoc.outputs - manifest = project.tasks.jar.manifest + manifest { + attributes( + // Basic JAR manifest attributes + 'Specification-Title': project.name, + 'Specification-Version': project.version, + 'Specification-Vendor': 'Hibernate.org', + 'Implementation-Title': project.name, + 'Implementation-Version': project.version, + 'Implementation-Vendor': 'Hibernate.org', + 'Implementation-Vendor-Id': 'org.hibernate', + 'Implementation-Url': 'http://hibernate.org/orm', + + // Hibernate-specific JAR manifest attributes + 'Hibernate-VersionFamily': project.ormVersion.family, + 'Hibernate-JpaVersion': project.jpaVersion.name + ) + } archiveClassifier.set( 'javadoc' ) } diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index c8abd8c3d1..19b46d3976 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -136,39 +136,54 @@ dependencies { jar { manifest { - mainAttributes( 'Main-Class': 'org.hibernate.Version' ) + attributes( + 'Main-Class': 'org.hibernate.Version', - instructionFirst 'Import-Package', - 'javax.security.auth;resolution:=optional', - 'javax.security.jacc;resolution:=optional', - 'javax.validation;resolution:=optional', - 'javax.validation.constraints;resolution:=optional', - 'javax.validation.groups;resolution:=optional', - 'javax.validation.metadata;resolution:=optional', - // TODO: Shouldn't have to explicitly list this, but the plugin - // generates it with a [1.0,2) version. - "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", - // optionals - 'javax.management;resolution:=optional', - 'javax.naming.event;resolution:=optional', - 'javax.naming.spi;resolution:=optional', - 'org.apache.tools.ant;resolution:=optional', - 'org.apache.tools.ant.taskdefs;resolution:=optional', - 'org.apache.tools.ant.types;resolution:=optional', - '!javax.enterprise*', - 'javax.enterprise.context.spi;resolution:=optional', - 'javax.enterprise.inject.spi;resolution:=optional', - 'javax.inject;resolution:=optional', - 'net.bytebuddy.*;resolution:=optional', - // We must specify the version explicitly to allow Karaf - // to use an older version of JAXB (the only one we can use in Karaf) - "javax.xml.bind.*;version=\"${project.jaxbApiVersionOsgiRange}\"" - -// // TODO: Uncomment once EntityManagerFactoryBuilderImpl no longer -// // uses ClassLoaderServiceImpl. -// instruction 'Export-Package', -// 'org.hibernate.boot.registry.classloading.internal', -// '*' + // BND Plugin instructions (for OSGi): + 'Import-Package': [ + 'javax.security.auth;resolution:=optional', + // Make javax.security.jacc optional and do not reference a version range (because that's what we used to do) + 'javax.security.jacc;resolution:=optional;version=!', + // Make javax.validation optional and do not reference a version range (because that's what we used to do) + 'javax.validation;resolution:=optional;version=!', + 'javax.validation.constraints;resolution:=optional;version=!', + 'javax.validation.groups;resolution:=optional;version=!', + 'javax.validation.metadata;resolution:=optional;version=!', + // Make javax.enterprise optional and do not reference a version range (because that's what we used to do) + '!javax.enterprise*', + 'javax.enterprise.context.spi;resolution:=optional;version=!', + 'javax.enterprise.inject.spi;resolution:=optional;version=!', + // For JPA, we don't want to target the automatically generated range, but a specific version + "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", + // optionals + 'javax.management;resolution:=optional', + 'javax.naming.event;resolution:=optional', + 'javax.naming.spi;resolution:=optional', + 'org.apache.tools.ant;resolution:=optional', + 'org.apache.tools.ant.taskdefs;resolution:=optional', + 'org.apache.tools.ant.types;resolution:=optional', + 'javax.inject;resolution:=optional', + 'net.bytebuddy.*;resolution:=optional', + 'org.objectweb.jonas_tm;resolution:=optional', + 'com.ibm.websphere.jtaextensions;resolution:=optional', + // We must specify the version explicitly to allow Karaf + // to use an older version of JAXB (the only one we can use in Karaf) + "javax.xml.bind.*;version=\"${project.jaxbApiVersionOsgiRange}\"", + // Temporarily support JTA 1.1 -- Karaf and other frameworks still + // use it. Without this, the plugin generates [1.2,2). + 'javax.transaction;version="[1.1,2)"', + // Also import every package referenced in the code + '*' + ].join( ',' ), + '-exportcontents': [ + // Legacy resource packages containing XSDs that were traditionally not exported + "!org.hibernate.xsd.cfg", + "!org.hibernate.xsd.mapping", + // TODO: Uncomment once EntityManagerFactoryBuilderImpl no longer uses ClassLoaderServiceImpl. + //'org.hibernate.boot.registry.classloading.internal', + "*;version=${project.version}" + ].join( ',' ), + ) } } diff --git a/hibernate-entitymanager/hibernate-entitymanager.gradle b/hibernate-entitymanager/hibernate-entitymanager.gradle index 02f16c8234..af066a55fe 100644 --- a/hibernate-entitymanager/hibernate-entitymanager.gradle +++ b/hibernate-entitymanager/hibernate-entitymanager.gradle @@ -12,19 +12,21 @@ dependencies { compile( libraries.jta ) } - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// The OSGi JAR manifest support does not like a non-existent classes dir, -// so make sure we dont use the OSGi one :) +// Traditionally we used to not include any manifest attributes in this JAR +// except "Manifest-Version" +// Since it's a legacy JAR, let's continue that way until it's retired. jar { - manifest = null + manifest.attributes.removeAll { key, value -> key != "Manifest-Version" } + // Prevent BND from adding manifest attributes automatically + bnd( '-nobundles': 'true' ) } sourcesJar { - manifest = null + manifest.attributes.removeAll { key, value -> key != "Manifest-Version" } } javadocJar { - manifest = null + manifest.attributes.removeAll { key, value -> key != "Manifest-Version" } } diff --git a/hibernate-envers/hibernate-envers.gradle b/hibernate-envers/hibernate-envers.gradle index ad98fd0286..8498523418 100644 --- a/hibernate-envers/hibernate-envers.gradle +++ b/hibernate-envers/hibernate-envers.gradle @@ -40,16 +40,25 @@ sourceSets { jar { manifest { - instructionFirst 'Import-Package', - // TODO: Shouldn't have to explicitly list the JPA packages, but - // the plugin generates them with [1.0,2) versions. - "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", - "javax.persistence.criteria;version=\"${project.jpaVersion.osgiName}\"", - "javax.persistence.metamodel;version=\"${project.jpaVersion.osgiName}\"", - "javax.persistence.spi;version=\"${project.jpaVersion.osgiName}\"", - // optionals - 'javax.naming;resolution:=optional', - 'org.apache.tools.ant;resolution:=optional' + attributes( + // BND Plugin instructions (for OSGi): + 'Import-Package': [ + // TODO: Shouldn't have to explicitly list the JPA packages, but + // the plugin generates them with [1.0,2) versions. + "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", + "javax.persistence.criteria;version=\"${project.jpaVersion.osgiName}\"", + "javax.persistence.metamodel;version=\"${project.jpaVersion.osgiName}\"", + "javax.persistence.spi;version=\"${project.jpaVersion.osgiName}\"", + // optionals + 'javax.naming;resolution:=optional', + 'org.apache.tools.ant;resolution:=optional', + // Temporarily support JTA 1.1 -- Karaf and other frameworks still + // use it. Without this, the plugin generates [1.2,2). + 'javax.transaction;version="[1.1,2)"', + // Also import every package referenced in the code + '*' + ].join( ',' ) + ) } } diff --git a/hibernate-java8/hibernate-java8.gradle b/hibernate-java8/hibernate-java8.gradle index 784184e95a..32c13a4603 100644 --- a/hibernate-java8/hibernate-java8.gradle +++ b/hibernate-java8/hibernate-java8.gradle @@ -6,18 +6,22 @@ description = '(deprecated - use hibernate-core instead) Support for Java8-speci dependencies { compile( project( ':hibernate-core' ) ) } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// The OSGi JAR manifest support does not like a non-existent classes dir, -// so make sure we dont use the OSGi one :) +// Traditionally we used to not include any manifest attributes in this JAR +// except "Manifest-Version" +// Since it's a legacy JAR, let's continue that way until it's retired. jar { - manifest = null + manifest.attributes.removeAll { key, value -> key != "Manifest-Version" } + // Prevent BND from adding manifest attributes automatically + bnd( '-nobundles': 'true' ) } sourcesJar { - manifest = null + manifest.attributes.removeAll { key, value -> key != "Manifest-Version" } } javadocJar { - manifest = null + manifest.attributes.removeAll { key, value -> key != "Manifest-Version" } } diff --git a/hibernate-osgi/hibernate-osgi.gradle b/hibernate-osgi/hibernate-osgi.gradle index 90a0e912f5..96d9fd8800 100644 --- a/hibernate-osgi/hibernate-osgi.gradle +++ b/hibernate-osgi/hibernate-osgi.gradle @@ -98,13 +98,22 @@ dependencies { jar { manifest { - instruction 'Bundle-Activator', 'org.hibernate.osgi.HibernateBundleActivator' - instruction 'Provide-Capability', 'osgi.service;effective:=active;objectClass=javax.persistence.spi.PersistenceProvider' - instructionFirst 'Import-Package', - // TODO: Shouldn't have to explicitly list this, but the plugin - // generates it with a [1.0,2) version. - "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", - "javax.persistence.spi;version=\"${project.jpaVersion.osgiName}\"" + attributes( + // BND Plugin instructions (for OSGi): + 'Bundle-Activator': 'org.hibernate.osgi.HibernateBundleActivator', + 'Provide-Capability': 'osgi.service;effective:=active;objectClass=javax.persistence.spi.PersistenceProvider', + 'Import-Package': [ + // TODO: Shouldn't have to explicitly list this, but the plugin + // generates it with a [1.0,2) version. + "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", + "javax.persistence.spi;version=\"${project.jpaVersion.osgiName}\"", + // Temporarily support JTA 1.1 -- Karaf and other frameworks still + // use it. Without this, the plugin generates [1.2,2). + 'javax.transaction;version="[1.1,2)"', + // Also import every package referenced in the code + '*' + ].join( ',' ) + ) } }