From 82f2aa0d5d4447cbb3c7f28fbe7c5e3b51ab1810 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 30 Apr 2018 10:38:09 -0500 Subject: [PATCH] HHH-12474 - Make sure the JPA version is defined by a single property across build files added HibernateVersion following pattern of JpaVersion --- documentation/documentation.gradle | 19 +++++++--- gradle/base-information.gradle | 37 +++++++++++++++---- gradle/published-java-module.gradle | 4 +- gradle/publishing-repos.gradle | 2 +- hibernate-core/hibernate-core.gradle | 2 +- .../hibernate-orm-modules.gradle | 8 ++-- release/release.gradle | 6 +-- 7 files changed, 54 insertions(+), 24 deletions(-) diff --git a/documentation/documentation.gradle b/documentation/documentation.gradle index 2a7b720f89..d67d2568aa 100644 --- a/documentation/documentation.gradle +++ b/documentation/documentation.gradle @@ -68,7 +68,7 @@ dependencies { } -if ( project.isSnapshot ) { +if ( project.ormVersion.isSnapshot ) { // only run the ci build tasks for SNAPSHOT versions task ciBuild( dependsOn: [clean, test] ) } @@ -161,7 +161,11 @@ task renderTopicalGuides(type: AsciidoctorTask, group: 'Documentation') { backends "html5" separateOutputDirs false options logDocuments: true - attributes icons: 'font', experimental: true, 'source-highlighter': 'prettify', majorMinorVersion: rootProject.hibernateMajorMinorVersion, fullVersion: rootProject.hibernateVersion + attributes icons: 'font', + experimental: true, + 'source-highlighter': 'prettify', + majorMinorVersion: rootProject.ormVersion.family, + fullVersion: rootProject.ormVersion.fullName resources { from('src/main/asciidoc/topical/') { include '**/images/**' @@ -231,8 +235,8 @@ task renderUserGuide(type: AsciidoctorTask, group: 'Documentation') { 'source-highlighter': 'prettify', linkcss: true, stylesheet: "css/hibernate.css", - majorMinorVersion: rootProject.hibernateMajorMinorVersion, - fullVersion: rootProject.hibernateVersion, + majorMinorVersion: rootProject.ormVersion.family, + fullVersion: rootProject.ormVersion.fullName, docinfo: true resources { @@ -260,7 +264,12 @@ task renderIntegrationGuide(type: AsciidoctorTask, group: 'Documentation') { backends "html5" separateOutputDirs false options logDocuments: true - attributes icons: 'font', experimental: true, 'source-highlighter': 'prettify', linkcss: true, stylesheet: "css/hibernate.css", majorMinorVersion: rootProject.hibernateMajorMinorVersion + attributes icons: 'font', + experimental: true, + 'source-highlighter': 'prettify', + linkcss: true, + stylesheet: "css/hibernate.css", + majorMinorVersion: rootProject.ormVersion.family resources { from('src/main/asciidoc/integrationguide/') { include 'images/**' diff --git a/gradle/base-information.gradle b/gradle/base-information.gradle index a711bbe02f..f90fccb297 100644 --- a/gradle/base-information.gradle +++ b/gradle/base-information.gradle @@ -8,19 +8,13 @@ apply plugin: 'base' ext { - hibernateVersion = '5.3.0-SNAPSHOT' + ormVersion = new HibernateVersion( '5.3.0-SNAPSHOT', project ) baselineJavaVersion = '1.8' jpaVersion = new JpaVersion('2.2') - - final String[] hibernateVersionComponents = project.hibernateVersion.split( '\\.' ) - hibernateMajorMinorVersion = hibernateVersionComponents[0] + '.' + hibernateVersionComponents[1] - hibernateMajorVersion = hibernateVersionComponents[0] - - isSnapshot = project.hibernateVersion.endsWith( "-SNAPSHOT" ) } group = 'org.hibernate' -version = project.hibernateVersion +version = project.ormVersion.fullName class JpaVersion { /** The *normal* name (1.0, 2.0, ..) */ @@ -38,3 +32,30 @@ class JpaVersion { return name } } + +class HibernateVersion { + final String fullName + final String majorVersion + final String family + + final String osgiVersion + + final boolean isSnapshot + + HibernateVersion(String fullName, Project project) { + this.fullName = fullName + + final String[] hibernateVersionComponents = fullName.split( '\\.' ) + this.majorVersion = hibernateVersionComponents[0] + this.family = hibernateVersionComponents[0] + '.' + hibernateVersionComponents[1] + + this.isSnapshot = fullName.endsWith( '-SNAPSHOT' ) + + this.osgiVersion = isSnapshot ? family + '.' + hibernateVersionComponents[2] + '.SNAPSHOT' : fullName + } + + @Override + String toString() { + return this.fullName + } +} \ No newline at end of file diff --git a/gradle/published-java-module.gradle b/gradle/published-java-module.gradle index a827bc9fd7..3d55956ca8 100644 --- a/gradle/published-java-module.gradle +++ b/gradle/published-java-module.gradle @@ -37,7 +37,7 @@ jar { symbolicName project.java9ModuleName vendor 'Hibernate.org' description project.description - docURL "http://www.hibernate.org/orm/${project.hibernateMajorMinorVersion}" + docURL "http://www.hibernate.org/orm/${project.ormVersion.family}" instruction 'Import-Package', // Temporarily support JTA 1.1 -- Karaf and other frameworks still @@ -58,7 +58,7 @@ jar { instruction 'Implementation-Vendor-Id', 'org.hibernate' instruction 'Implementation-Url', 'http://hibernate.org/orm' - instruction 'Hibernate-VersionFamily', project.hibernateMajorMinorVersion + instruction 'Hibernate-VersionFamily', project.ormVersion.family instruction 'Hibernate-JpaVersion', project.jpaVersion.name } } diff --git a/gradle/publishing-repos.gradle b/gradle/publishing-repos.gradle index 94b13c39b4..7a5031b47b 100644 --- a/gradle/publishing-repos.gradle +++ b/gradle/publishing-repos.gradle @@ -54,7 +54,7 @@ bintray { } attributes = [ 'jpa': project.jpaVersion, - 'family': project.hibernateMajorMinorVersion + 'family': project.ormVersion.family ] mavenCentralSync { sync = true diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 25d8a0959f..ed043beb12 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -216,7 +216,7 @@ processTestResources { include 'arquillian.xml' include 'org/hibernate/test/wf/ddl/manifest.mf' expand wildFlyInstallDir: project( ':hibernate-orm-modules' ).wildFlyInstallDir, - hibernateMajorMinorVersion: "${project.hibernateMajorMinorVersion}", + hibernateMajorMinorVersion: "${project.ormVersion.family}", arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments" } } diff --git a/hibernate-orm-modules/hibernate-orm-modules.gradle b/hibernate-orm-modules/hibernate-orm-modules.gradle index 414c659285..cc46568626 100644 --- a/hibernate-orm-modules/hibernate-orm-modules.gradle +++ b/hibernate-orm-modules/hibernate-orm-modules.gradle @@ -68,11 +68,11 @@ featurepack { configurationName 'featurePack' // Variables to be replaced in the template. N.B. not all variables need to be replaced! // Exact ORM version, e.g. "5.3.0.Final" - variables['slot'] = rootProject.hibernateVersion + variables['slot'] = rootProject.ormVersion.fullName // Just the minor ORM version, e.g. "5.3"; Is used as an alias for the exact version - variables['minorSlot'] = rootProject.hibernateMajorMinorVersion + variables['minorSlot'] = rootProject.ormVersion.family variables['bytebuddySlot'] = bytebuddyVersion - variables['infinispan2lcSlot'] = 'for-orm-' + rootProject.hibernateMajorMinorVersion + variables['infinispan2lcSlot'] = 'for-orm-' + rootProject.ormVersion.family //Dependency on another Feature Pack: dependency "org.wildfly:wildfly-feature-pack:${project.wildflyVersion}" // It will assume it is "zip" by default //Ensure we declare all source repositories explicitly @@ -102,7 +102,7 @@ provision { version = '5.0.2.Final' }*/ variables['wildfly.version'] = project.wildflyVersion - variables['hibernate-orm.version'] = rootProject.hibernateVersion + variables['hibernate-orm.version'] = rootProject.ormVersion.fullName //Ensure we declare all source repositories explicitly autoAddRepositories = false } diff --git a/release/release.gradle b/release/release.gradle index 82ec012123..4ed9b78650 100644 --- a/release/release.gradle +++ b/release/release.gradle @@ -65,13 +65,13 @@ task assembleDocumentation(type: Task, dependsOn: [rootProject.project( 'documen task uploadDocumentation(type:Exec, dependsOn: assembleDocumentation) { description = "Uploads documentation to the JBoss doc server" - final String url = "filemgmt.jboss.org:/docs_htdocs/hibernate/orm/${rootProject.hibernateMajorMinorVersion}"; + final String url = "filemgmt.jboss.org:/docs_htdocs/hibernate/orm/${rootProject.ormVersion.family}"; executable 'rsync' args '-avz', '--links', '--protocol=28', "${documentationDir.absolutePath}/", url doFirst { - if ( version.endsWith( "SNAPSHOT" ) ) { + if ( rootProject.ormVersion.isSnapshot ) { logger.error( "Cannot perform upload of SNAPSHOT documentation" ); throw new RuntimeException( "Cannot perform upload of SNAPSHOT documentation" ); } @@ -214,7 +214,7 @@ task uploadBundlesSourceForge(type: Exec, dependsOn: buildBundles) { args '-vr', '-e ssh', "${project.buildDir}/distributions/", url doFirst { - if ( version.endsWith( "SNAPSHOT" ) ) { + if ( rootProject.ormVersion.isSnapshot ) { logger.error( "Cannot perform upload of SNAPSHOT bundles to SourceForge" ); throw new RuntimeException( "Cannot perform upload of SNAPSHOT bundles to SourceForge" ) }