diff --git a/.gitignore b/.gitignore index d55ee251da..08499b7950 100644 --- a/.gitignore +++ b/.gitignore @@ -103,4 +103,4 @@ virtualenv/ # Files you may find useful to have in your working directory. PLAN NOTES -TODO +TODO \ No newline at end of file diff --git a/build.gradle b/build.gradle index 49d8d4a5ee..df28f0e5d4 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,9 @@ buildscript { file("$projectDir/constants.properties").withInputStream { constants.load(it) } // Our version: bump this on release. - ext.corda_release_version = constants.getProperty("cordaVersion") + ext.baseVersion = constants.getProperty("cordaVersion") + ext.versionSuffix = constants.getProperty("versionSuffix") + ext.corda_platform_version = constants.getProperty("platformVersion") ext.gradle_plugins_version = constants.getProperty("gradlePluginsVersion") @@ -190,7 +192,8 @@ plugins { // Add the shadow plugin to the plugins classpath for the entire project. id 'com.github.johnrengelman.shadow' version '2.0.4' apply false id "com.gradle.build-scan" version "2.2.1" -} + id "org.ajoberstar.grgit" version "4.0.0" + } apply plugin: 'project-report' apply plugin: 'com.github.ben-manes.versions' @@ -199,6 +202,20 @@ apply plugin: 'maven-publish' apply plugin: 'com.jfrog.artifactory' apply plugin: "com.bmuschko.docker-remote-api" + +// If the command line project option -PversionFromGit is added to the gradle invocation, we'll resolve +// the latest git commit hash and timestamp and create a version postfix from that +if (project.hasProperty("versionFromGit")){ + ext.versionSuffix = "${grgit.head().dateTime.format("yyyyMMdd_HHmmss")}-${grgit.head().abbreviatedId}" +} + +// Need the `toString()` call on these, because they need to be converted from GStringImpl to Java Strings. +if (ext.versionSuffix != ""){ + ext.corda_release_version = "${ext.baseVersion}-${ext.versionSuffix}".toString() +} else { + ext.corda_release_version = "${ext.baseVersion}".toString() +} + // We need the following three lines even though they're inside an allprojects {} block below because otherwise // IntelliJ gets confused when importing the project and ends up erasing and recreating the .idea directory, along // with the run configurations. It also doesn't realise that the project is a Java 8 project and misconfigures diff --git a/constants.properties b/constants.properties index 6e4f55adfa..491d6813c6 100644 --- a/constants.properties +++ b/constants.properties @@ -2,7 +2,8 @@ # because some versions here need to be matched by app authors in # their own projects. So don't get fancy with syntax! -cordaVersion=4.4-SNAPSHOT +cordaVersion=4.4 +versionSuffix=SNAPSHOT gradlePluginsVersion=5.0.6 kotlinVersion=1.2.71 java8MinUpdateVersion=171