diff --git a/build.gradle b/build.gradle index eea9b1ba80..27dfbb9da0 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ buildscript { plugins { id 'me.champeau.buildscan-recipes' version '0.2.3' id 'io.github.gradle-nexus.publish-plugin' version '1.0.0' - id 'nu.studer.credentials' version '2.1' apply false + id 'nu.studer.credentials' version '2.1' id 'org.hibernate.build.xjc' version '2.0.1' apply false id 'org.hibernate.build.maven-repo-auth' version '3.0.3' apply false id 'biz.aQute.bnd' version '5.1.1' apply false @@ -33,10 +33,22 @@ ext { sonatypeOssrhPassword = project.findProperty( 'SONATYPE_OSSRH_PASSWORD' ) } -// nexusPublishing uses group and version -// as defaults -group = project.group -version = project.version +File versionFile = file( "${rootProject.projectDir}/gradle/version.properties" ) + +ext { + ormVersionFile = versionFile + ormVersion = HibernateVersion.fromFile( versionFile, project ) + // Override during releases + if ( project.hasProperty( 'releaseVersion' ) ) { + ormVersion = new HibernateVersion( project.releaseVersion, project ) + } + jpaVersion = new JpaVersion('2.2') +} + +// The Gradle Nexus Publish Plugin must be applied to the root project and requires group and version + +group = 'org.hibernate' +version = project.ormVersion.fullName nexusPublishing { repositories { @@ -60,13 +72,11 @@ allprojects { } apply plugin: 'idea' - group = project.group - version = project.version - // minimize changes, at least for now (gradle uses 'build' by default).. buildDir = "target" - apply from: rootProject.file( 'gradle/base-information.gradle' ) + group = 'org.hibernate' + version = project.ormVersion.fullName } @@ -125,6 +135,66 @@ buildScanRecipes { recipe 'git-commit', baseUrl: 'https://github.com/hibernate/hibernate-orm/tree' } +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 + } +} + +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 + } + + static HibernateVersion fromFile(File file, Project project){ + def fullName = readVersionProperties(file) + return new HibernateVersion(fullName, project) + } + + private static String readVersionProperties(File file) { + if ( !file.exists() ) { + throw new GradleException( "Version file $file.canonicalPath does not exists" ) + } + Properties versionProperties = new Properties() + file.withInputStream { + stream -> versionProperties.load( stream ) + } + return versionProperties.hibernateVersion + } + + @Override + String toString() { + return this.fullName + } +} + //idea { // project { // jdkName = gradle.ext.baselineJavaVersion diff --git a/gradle/base-information.gradle b/gradle/base-information.gradle deleted file mode 100644 index d3d00808e1..0000000000 --- a/gradle/base-information.gradle +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 - */ - -apply plugin: 'base' - -File versionFile = file( "${rootProject.projectDir}/gradle/version.properties" ) - -ext { - ormVersionFile = versionFile - ormVersion = HibernateVersion.fromFile( versionFile, project ) - // Override during releases - if ( project.hasProperty( 'releaseVersion' ) ) { - ormVersion = new HibernateVersion( project.releaseVersion, project ) - } - jpaVersion = new JpaVersion('2.2') -} - -group = 'org.hibernate' -version = project.ormVersion.fullName - -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 - } -} - -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 - } - - static HibernateVersion fromFile(File file, Project project){ - def fullName = readVersionProperties(file) - return new HibernateVersion(fullName, project) - } - - private static String readVersionProperties(File file) { - if ( !file.exists() ) { - throw new GradleException( "Version file $file.canonicalPath does not exists" ) - } - Properties versionProperties = new Properties() - file.withInputStream { - stream -> versionProperties.load( stream ) - } - return versionProperties.hibernateVersion - } - - @Override - String toString() { - return this.fullName - } -} diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index fee82c2567..e3d60db623 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -21,7 +21,6 @@ import org.apache.tools.ant.filters.ReplaceTokens * Support for modules that contain Java code */ -apply from: rootProject.file( 'gradle/base-information.gradle' ) apply from: rootProject.file( 'gradle/libraries.gradle' ) apply from: rootProject.file( 'gradle/databases.gradle' ) diff --git a/gradle/publishing-repos.gradle b/gradle/publishing-repos.gradle index 0d33df825d..77b3bfdc39 100644 --- a/gradle/publishing-repos.gradle +++ b/gradle/publishing-repos.gradle @@ -5,9 +5,6 @@ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -apply from: rootProject.file( 'gradle/base-information.gradle' ) - - apply plugin: 'maven-publish' apply plugin: 'org.hibernate.build.maven-repo-auth' diff --git a/hibernate-infinispan/hibernate-infinispan.gradle b/hibernate-infinispan/hibernate-infinispan.gradle index 893f58bf0f..d7784beed0 100644 --- a/hibernate-infinispan/hibernate-infinispan.gradle +++ b/hibernate-infinispan/hibernate-infinispan.gradle @@ -7,7 +7,6 @@ description = '(deprecated - use org.infinispan:infinispan-hibernate-cache-v53 instead)' -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' diff --git a/release/release.gradle b/release/release.gradle index 8b6304abc3..ee6ae330fb 100644 --- a/release/release.gradle +++ b/release/release.gradle @@ -8,8 +8,6 @@ import groovy.json.JsonSlurper * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -apply from: rootProject.file( 'gradle/base-information.gradle' ) - apply plugin: 'idea' apply plugin: 'distribution'