HHH-12474 - Make sure the JPA version is defined by a single property across build files

added HibernateVersion following pattern of JpaVersion
This commit is contained in:
Steve Ebersole 2018-04-30 10:38:09 -05:00
parent 7938918518
commit 82f2aa0d5d
7 changed files with 54 additions and 24 deletions

View File

@ -68,7 +68,7 @@ dependencies {
} }
if ( project.isSnapshot ) { if ( project.ormVersion.isSnapshot ) {
// only run the ci build tasks for SNAPSHOT versions // only run the ci build tasks for SNAPSHOT versions
task ciBuild( dependsOn: [clean, test] ) task ciBuild( dependsOn: [clean, test] )
} }
@ -161,7 +161,11 @@ task renderTopicalGuides(type: AsciidoctorTask, group: 'Documentation') {
backends "html5" backends "html5"
separateOutputDirs false separateOutputDirs false
options logDocuments: true 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 { resources {
from('src/main/asciidoc/topical/') { from('src/main/asciidoc/topical/') {
include '**/images/**' include '**/images/**'
@ -231,8 +235,8 @@ task renderUserGuide(type: AsciidoctorTask, group: 'Documentation') {
'source-highlighter': 'prettify', 'source-highlighter': 'prettify',
linkcss: true, linkcss: true,
stylesheet: "css/hibernate.css", stylesheet: "css/hibernate.css",
majorMinorVersion: rootProject.hibernateMajorMinorVersion, majorMinorVersion: rootProject.ormVersion.family,
fullVersion: rootProject.hibernateVersion, fullVersion: rootProject.ormVersion.fullName,
docinfo: true docinfo: true
resources { resources {
@ -260,7 +264,12 @@ task renderIntegrationGuide(type: AsciidoctorTask, group: 'Documentation') {
backends "html5" backends "html5"
separateOutputDirs false separateOutputDirs false
options logDocuments: true 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 { resources {
from('src/main/asciidoc/integrationguide/') { from('src/main/asciidoc/integrationguide/') {
include 'images/**' include 'images/**'

View File

@ -8,19 +8,13 @@
apply plugin: 'base' apply plugin: 'base'
ext { ext {
hibernateVersion = '5.3.0-SNAPSHOT' ormVersion = new HibernateVersion( '5.3.0-SNAPSHOT', project )
baselineJavaVersion = '1.8' baselineJavaVersion = '1.8'
jpaVersion = new JpaVersion('2.2') 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' group = 'org.hibernate'
version = project.hibernateVersion version = project.ormVersion.fullName
class JpaVersion { class JpaVersion {
/** The *normal* name (1.0, 2.0, ..) */ /** The *normal* name (1.0, 2.0, ..) */
@ -38,3 +32,30 @@ class JpaVersion {
return name 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
}
}

View File

@ -37,7 +37,7 @@ jar {
symbolicName project.java9ModuleName symbolicName project.java9ModuleName
vendor 'Hibernate.org' vendor 'Hibernate.org'
description project.description description project.description
docURL "http://www.hibernate.org/orm/${project.hibernateMajorMinorVersion}" docURL "http://www.hibernate.org/orm/${project.ormVersion.family}"
instruction 'Import-Package', instruction 'Import-Package',
// Temporarily support JTA 1.1 -- Karaf and other frameworks still // Temporarily support JTA 1.1 -- Karaf and other frameworks still
@ -58,7 +58,7 @@ jar {
instruction 'Implementation-Vendor-Id', 'org.hibernate' instruction 'Implementation-Vendor-Id', 'org.hibernate'
instruction 'Implementation-Url', 'http://hibernate.org/orm' instruction 'Implementation-Url', 'http://hibernate.org/orm'
instruction 'Hibernate-VersionFamily', project.hibernateMajorMinorVersion instruction 'Hibernate-VersionFamily', project.ormVersion.family
instruction 'Hibernate-JpaVersion', project.jpaVersion.name instruction 'Hibernate-JpaVersion', project.jpaVersion.name
} }
} }

View File

@ -54,7 +54,7 @@ bintray {
} }
attributes = [ attributes = [
'jpa': project.jpaVersion, 'jpa': project.jpaVersion,
'family': project.hibernateMajorMinorVersion 'family': project.ormVersion.family
] ]
mavenCentralSync { mavenCentralSync {
sync = true sync = true

View File

@ -216,7 +216,7 @@ processTestResources {
include 'arquillian.xml' include 'arquillian.xml'
include 'org/hibernate/test/wf/ddl/manifest.mf' include 'org/hibernate/test/wf/ddl/manifest.mf'
expand wildFlyInstallDir: project( ':hibernate-orm-modules' ).wildFlyInstallDir, expand wildFlyInstallDir: project( ':hibernate-orm-modules' ).wildFlyInstallDir,
hibernateMajorMinorVersion: "${project.hibernateMajorMinorVersion}", hibernateMajorMinorVersion: "${project.ormVersion.family}",
arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments" arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments"
} }
} }

View File

@ -68,11 +68,11 @@ featurepack {
configurationName 'featurePack' configurationName 'featurePack'
// Variables to be replaced in the template. N.B. not all variables need to be replaced! // 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" // 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 // 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['bytebuddySlot'] = bytebuddyVersion
variables['infinispan2lcSlot'] = 'for-orm-' + rootProject.hibernateMajorMinorVersion variables['infinispan2lcSlot'] = 'for-orm-' + rootProject.ormVersion.family
//Dependency on another Feature Pack: //Dependency on another Feature Pack:
dependency "org.wildfly:wildfly-feature-pack:${project.wildflyVersion}" // It will assume it is "zip" by default dependency "org.wildfly:wildfly-feature-pack:${project.wildflyVersion}" // It will assume it is "zip" by default
//Ensure we declare all source repositories explicitly //Ensure we declare all source repositories explicitly
@ -102,7 +102,7 @@ provision {
version = '5.0.2.Final' version = '5.0.2.Final'
}*/ }*/
variables['wildfly.version'] = project.wildflyVersion 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 //Ensure we declare all source repositories explicitly
autoAddRepositories = false autoAddRepositories = false
} }

View File

@ -65,13 +65,13 @@ task assembleDocumentation(type: Task, dependsOn: [rootProject.project( 'documen
task uploadDocumentation(type:Exec, dependsOn: assembleDocumentation) { task uploadDocumentation(type:Exec, dependsOn: assembleDocumentation) {
description = "Uploads documentation to the JBoss doc server" 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' executable 'rsync'
args '-avz', '--links', '--protocol=28', "${documentationDir.absolutePath}/", url args '-avz', '--links', '--protocol=28', "${documentationDir.absolutePath}/", url
doFirst { doFirst {
if ( version.endsWith( "SNAPSHOT" ) ) { if ( rootProject.ormVersion.isSnapshot ) {
logger.error( "Cannot perform upload of SNAPSHOT documentation" ); logger.error( "Cannot perform upload of SNAPSHOT documentation" );
throw new RuntimeException( "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 args '-vr', '-e ssh', "${project.buildDir}/distributions/", url
doFirst { doFirst {
if ( version.endsWith( "SNAPSHOT" ) ) { if ( rootProject.ormVersion.isSnapshot ) {
logger.error( "Cannot perform upload of SNAPSHOT bundles to SourceForge" ); logger.error( "Cannot perform upload of SNAPSHOT bundles to SourceForge" );
throw new RuntimeException( "Cannot perform upload of SNAPSHOT bundles to SourceForge" ) throw new RuntimeException( "Cannot perform upload of SNAPSHOT bundles to SourceForge" )
} }