geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [10/16] incubator-geode git commit: GEODE-1260: Cache SCM metadata for source distributions
Date Tue, 10 May 2016 21:17:11 GMT
GEODE-1260: Cache SCM metadata for source distributions

The GemFireVersion.properties file is generated by the build and
contains the git branch, commit, and source date. This change
caches the SCM info in the build root (.buildinfo) for use by the
source distribution.

Actually works this time.


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

Branch: refs/heads/feature/GEODE-1370
Commit: 44c2f398ff0a67d3e639c224c7df3ec861fe2c70
Parents: c33de6d
Author: Anthony Baker <abaker@apache.org>
Authored: Wed May 4 15:19:39 2016 -0700
Committer: Anthony Baker <abaker@apache.org>
Committed: Mon May 9 19:48:25 2016 -0700

----------------------------------------------------------------------
 geode-assembly/build.gradle | 12 +++++++
 geode-core/build.gradle     | 68 +++++++++++++++++++++++-----------------
 gradle/rat.gradle           |  1 +
 3 files changed, 52 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44c2f398/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index e786b24..ed5154e 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -227,6 +227,17 @@ task docs(type: Javadoc) {
    }
 }
 
+task writeBuildInfo {
+  def buildInfo = file "$buildDir/.buildinfo"
+  outputs.file buildInfo
+  doLast {
+    buildInfo.getParentFile().mkdirs();
+    new FileOutputStream(buildInfo).withStream { fos ->
+      project(':geode-core').readScmInfo().store(fos, '')
+    }
+  }
+}
+
 gradle.taskGraph.whenReady( { graph ->
   tasks.withType(AbstractArchiveTask).findAll {
     it.name.toLowerCase().contains("dist")
@@ -242,6 +253,7 @@ distributions {
   src {
     baseName = 'apache-geode-src'
     contents {
+      from writeBuildInfo
       from (rootDir) {
         exclude 'KEYS'
         exclude 'gradlew'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44c2f398/geode-core/build.gradle
----------------------------------------------------------------------
diff --git a/geode-core/build.gradle b/geode-core/build.gradle
index 45051dc..8cd5bf3 100755
--- a/geode-core/build.gradle
+++ b/geode-core/build.gradle
@@ -131,7 +131,40 @@ sourceSets {
     output.dir(generatedResources, builtBy: 'createVersionPropertiesFile')
   }
 }
- 
+
+ext.readScmInfo = {
+  try {
+    def git = org.ajoberstar.grgit.Grgit.open(currentDir: projectDir)
+    try {
+      return [
+        'Source-Repository': git.branch.getCurrent().name,
+        'Source-Revision'  : git.head().id,
+        'Source-Date'      : git.head().getDate().format('yyyy-MM-dd HH:mm:ss Z')
+      ] as Properties
+    } finally {
+      git.close()
+    }
+  } catch (IllegalArgumentException e) {
+    // if we're building from the source distribution, we don't have git so
+    // use cached info written during the assembly process
+    def buildInfo = file "$rootDir/.buildinfo"
+    if (buildInfo.exists()) {
+      def props = new Properties()
+      new FileInputStream(buildInfo).withStream { fis ->
+        props.load(fis)
+      }
+      return props
+    }
+
+    logger.warn( '***** Unable to find Git workspace. Using default version information *****'
)
+    return [
+      'Source-Repository': 'UNKNOWN',
+      'Source-Revision'  : 'UNKNOWN',
+      'Source-Date'      : new Date().format('yyyy-MM-dd HH:mm:ss Z')
+    ] as Properties
+  }
+}
+
 // Creates the version properties file and writes it to the classes dir
 task createVersionPropertiesFile {
   def propertiesFile = file(generatedResources + "/com/gemstone/gemfire/internal/GemFireVersion.properties");
@@ -139,38 +172,15 @@ task createVersionPropertiesFile {
   inputs.dir compileJava.destinationDir
 
   doLast {
-
-    try {
-      def grgit = org.ajoberstar.grgit.Grgit.open(currentDir: projectDir)
-      ext.branch = grgit.branch.getCurrent().name
-      ext.commitId = grgit.head().id
-      ext.sourceDate = grgit.head().getDate().format('yyyy-MM-dd HH:mm:ss Z')
-      grgit.close()
-    } catch (Exception e) {
-      logger.warn( '***** Unable to find Git workspace. Using default version information
*****' )
-      ext.branch = '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')
-    ext.buildDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
-    ext.buildNumber = new Date().format('MMddyy')
-    ext.jdkVersion = System.getProperty('java.version')
-
     def props = [
       "Product-Name"      : "Apache Geode (incubating)",
       "Product-Version"   : version,
-      "Build-Id"          : System.env.USER + ' ' + ext.buildNumber,
-      "Build-Date"        : ext.buildDate,
-      "Build-Platform"    : ext.osName + ' ' + ext.osVersion + ' ' + ext.osArch,
-      "Build-Java-Version": ext.jdkVersion,
-      "Source-Date"       : ext.sourceDate,
-      "Source-Revision"   : ext.commitId,
-      "Source-Repository" : ext.branch
+      "Build-Id"          : "${System.env.USER} ${new Date().format('MMddyy')}".toString(),
+      "Build-Date"        : new Date().format('yyyy-MM-dd HH:mm:ss Z'),
+      "Build-Platform"    : "${System.properties['os.name']} ${System.properties['os.version']}
${System.properties['os.arch']}".toString(),
+      "Build-Java-Version": System.properties['java.version']
     ] as Properties
+    props.putAll(readScmInfo())
 
     propertiesFile.getParentFile().mkdirs();
     new FileOutputStream(propertiesFile).withStream { fos ->

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/44c2f398/gradle/rat.gradle
----------------------------------------------------------------------
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
index f35b157..3d0826a 100644
--- a/gradle/rat.gradle
+++ b/gradle/rat.gradle
@@ -37,6 +37,7 @@ rat {
     'native/**',
     'wrapper/**',
     '**/build/**',
+    '.buildinfo',
 
     // SBT
     'geode-spark-connector/**/target/**',


Mime
View raw message