ENT-4595 Add git based version (#5799)

* ENT-4595 Allow publishing a version with a git based version string

* ENT-4595 rename option and add comment

* ENT-4595 Fix groovy/Java string incompatibility

* Remove Constants.kt so it gets regenerated on a fresh check-out.

* Add Constants.kt to .gitignore

* Reverted deletion of Constants.kt as it would cause problems for IntelliJ users

* Reverted logging Constants.kt file to how it was before

* Undid template change too

* Reverted template file properly this time.
This commit is contained in:
Christian Sailer 2019-12-11 17:50:27 +00:00 committed by Jonathan Locke
parent 3fc916fb6c
commit b80d1b3009
3 changed files with 23 additions and 4 deletions

2
.gitignore vendored
View File

@ -103,4 +103,4 @@ virtualenv/
# Files you may find useful to have in your working directory.
PLAN
NOTES
TODO
TODO

View File

@ -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")
@ -186,7 +188,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"
}
ext {
}
@ -198,6 +201,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

View File

@ -2,7 +2,9 @@
# because some versions here need to be matched by app authors in
# their own projects. So don't get fancy with syntax!
cordaVersion=4.3-SNAPSHOT
cordaVersion=4.3
versionSuffix=SNAPSHOT
gradlePluginsVersion=5.0.4
kotlinVersion=1.2.71
java8MinUpdateVersion=171