geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbr...@apache.org
Subject incubator-geode git commit: [GEODE-42] Remove hardcoded versioning from GemFireVersion.properties file
Date Fri, 26 Jun 2015 22:10:04 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop dbab0cef4 -> 121978388


[GEODE-42] Remove hardcoded versioning from GemFireVersion.properties file

The version information was hardcoded in the initial drop of the Geode code base. This change
allows the build to get source revision information from Git, if available. If source information
is not available, then value  is 'UNKNOWN'.

Tested with and without Git workspace.

Reviewed by: amb


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/12197838
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/12197838
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/12197838

Branch: refs/heads/develop
Commit: 121978388681ea418eefd09269f8015f5eac7dca
Parents: dbab0ce
Author: mbretl <mbretl@apache.org>
Authored: Fri Jun 26 15:05:07 2015 -0700
Committer: mbretl <mbretl@apache.org>
Committed: Fri Jun 26 15:05:07 2015 -0700

----------------------------------------------------------------------
 gemfire-core/build.gradle | 44 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/12197838/gemfire-core/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle
index a03954a..0fff1e6 100755
--- a/gemfire-core/build.gradle
+++ b/gemfire-core/build.gradle
@@ -64,10 +64,46 @@ dependencies {
 
 // Creates the version properties file and writes it to the classes dir
 task createVersionPropertiesFile << {
-  ext.gitBranch = 'master'
-  ext.commitId = '1366ff2d4fcbf54bfad684e9ba9822db2a2b0ff5'
-  ext.sourceDate = '2015-04-06 14:54:51 -0700'
-  
+
+  def gitFolder = new File ("${rootProject.projectDir}/.git")
+  if ( gitFolder.exists() ) {
+    new ByteArrayOutputStream().withStream { gitBranchStream ->
+      def result = exec {
+        standardOutput = gitBranchStream
+        executable = "git"
+        args = ['rev-parse', '--abbrev-ref', 'HEAD']
+      }
+      ext.gitBranchString = gitBranchStream.toString()
+      ext.gitBranch = ext.gitBranchString.trim()
+    }
+
+    new ByteArrayOutputStream().withStream { commitStream ->
+      def result = exec {
+        standardOutput = commitStream
+        executable = "git"
+        args = ['rev-parse', 'HEAD']
+      }
+      ext.commitIdString = commitStream.toString()
+      ext.commitId = ext.commitIdString.trim()
+    }
+
+    new ByteArrayOutputStream().withStream { sourceDateStream ->
+      def result = exec {
+        standardOutput = sourceDateStream
+        executable = "git"
+        args = ['show', '-s', '--format=%ci', "${ext.commitId}"]
+      }
+      ext.sourceDateString = sourceDateStream.toString()
+      ext.sourceDate = ext.sourceDateString.trim()
+    }
+  }
+  else {
+    // Not in SCM workspace, use default values
+    ext.gitBranch = 'UNKNOWN'
+    ext.commitId = 'UNKNOWN'
+    ext.sourceDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
+  }
+
   ext.osArch = System.getProperty('os.arch')
   ext.osName = System.getProperty('os.name')
   ext.osVersion = System.getProperty('os.version')


Mime
View raw message