From e2b7317560bdb3248d9f5ec9f254a7bcecb31fb8 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 11 Apr 2018 19:18:19 +0100 Subject: [PATCH] HHH-12474 - Make sure the JPA version is defined by a single property across build files --- gradle/base-information.gradle | 21 +++++++++++++++++-- gradle/libraries.gradle | 2 +- gradle/published-java-module.gradle | 2 +- gradle/publishing-repos.gradle | 2 +- hibernate-core/hibernate-core.gradle | 2 +- hibernate-envers/hibernate-envers.gradle | 8 +++---- .../hibernate-orm-modules.gradle | 2 +- hibernate-osgi/hibernate-osgi.gradle | 4 ++-- 8 files changed, 30 insertions(+), 13 deletions(-) diff --git a/gradle/base-information.gradle b/gradle/base-information.gradle index 5c7a1563e6..a711bbe02f 100644 --- a/gradle/base-information.gradle +++ b/gradle/base-information.gradle @@ -10,7 +10,7 @@ apply plugin: 'base' ext { hibernateVersion = '5.3.0-SNAPSHOT' baselineJavaVersion = '1.8' - jpaVersion = '2.2' + jpaVersion = new JpaVersion('2.2') final String[] hibernateVersionComponents = project.hibernateVersion.split( '\\.' ) hibernateMajorMinorVersion = hibernateVersionComponents[0] + '.' + hibernateVersionComponents[1] @@ -20,4 +20,21 @@ ext { } group = 'org.hibernate' -version = project.hibernateVersion \ No newline at end of file +version = project.hibernateVersion + +class JpaVersion { + /** The *normal* name (1.0, 2.0, ..) */ + final String name; + + final String osgiName + + JpaVersion(String version){ + this.name = version + this.osgiName = version + ".0" + } + + @Override + String toString() { + return name + } +} diff --git a/gradle/libraries.gradle b/gradle/libraries.gradle index c86316ba76..0b418c14e9 100644 --- a/gradle/libraries.gradle +++ b/gradle/libraries.gradle @@ -60,7 +60,7 @@ ext { byteBuddy: "net.bytebuddy:byte-buddy:${byteBuddyVersion}", // javax - jpa: 'javax.persistence:javax.persistence-api:2.2', + jpa: "javax.persistence:javax.persistence-api:${project.jpaVersion}", jta: 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.1.Final', validation: "javax.validation:validation-api:${validationApiVersion}", jacc: 'org.jboss.spec.javax.security.jacc:jboss-jacc-api_1.4_spec:1.0.2.Final', diff --git a/gradle/published-java-module.gradle b/gradle/published-java-module.gradle index da084f082a..a827bc9fd7 100644 --- a/gradle/published-java-module.gradle +++ b/gradle/published-java-module.gradle @@ -59,7 +59,7 @@ jar { instruction 'Implementation-Url', 'http://hibernate.org/orm' instruction 'Hibernate-VersionFamily', project.hibernateMajorMinorVersion - instruction 'Hibernate-JpaVersion', project.jpaVersion + instruction 'Hibernate-JpaVersion', project.jpaVersion.name } } diff --git a/gradle/publishing-repos.gradle b/gradle/publishing-repos.gradle index 974cc66ef1..94b13c39b4 100644 --- a/gradle/publishing-repos.gradle +++ b/gradle/publishing-repos.gradle @@ -53,7 +53,7 @@ bintray { sign = true } attributes = [ - 'jpa': '2.2', + 'jpa': project.jpaVersion, 'family': project.hibernateMajorMinorVersion ] mavenCentralSync { diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 50263efd75..25d8a0959f 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -116,7 +116,7 @@ jar { '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="2.1.0"', + "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", // Temporarily support JTA 1.1 -- Karaf and other frameworks still // use it. Without this, the plugin generates [1.2,2). // build.gradle adds javax.transaction for all modules diff --git a/hibernate-envers/hibernate-envers.gradle b/hibernate-envers/hibernate-envers.gradle index d3140c90d4..90c67c5dc8 100644 --- a/hibernate-envers/hibernate-envers.gradle +++ b/hibernate-envers/hibernate-envers.gradle @@ -43,10 +43,10 @@ jar { 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="2.1.0"', - 'javax.persistence.criteria;version="2.1.0"', - 'javax.persistence.metamodel;version="2.1.0"', - 'javax.persistence.spi;version="2.1.0"', + "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' diff --git a/hibernate-orm-modules/hibernate-orm-modules.gradle b/hibernate-orm-modules/hibernate-orm-modules.gradle index b75c71e322..50857a7108 100644 --- a/hibernate-orm-modules/hibernate-orm-modules.gradle +++ b/hibernate-orm-modules/hibernate-orm-modules.gradle @@ -93,7 +93,7 @@ provision { override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) { groupId = 'javax.persistence' artifactId = 'javax.persistence-api' - version = '2.2' + version = project.jpaVersion } /**TODO: explore overriding any other library we might need? Example: (not currently necessary) diff --git a/hibernate-osgi/hibernate-osgi.gradle b/hibernate-osgi/hibernate-osgi.gradle index 8ee4aafd91..84dae24993 100644 --- a/hibernate-osgi/hibernate-osgi.gradle +++ b/hibernate-osgi/hibernate-osgi.gradle @@ -99,8 +99,8 @@ jar { 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="2.1.0"', - 'javax.persistence.spi;version="2.1.0"' + "javax.persistence;version=\"${project.jpaVersion.osgiName}\"", + "javax.persistence.spi;version=\"${project.jpaVersion.osgiName}\"" } }