geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject incubator-geode git commit: GEODE-1260: Cache SCM metadata for source distributions
Date Wed, 04 May 2016 01:38:45 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 8dc2d3031 -> 19b9fe5ad


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.


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

Branch: refs/heads/develop
Commit: 19b9fe5ad6b4a697c512304f3db92c91a02f4072
Parents: 8dc2d30
Author: Anthony Baker <abaker@apache.org>
Authored: Mon May 2 20:41:41 2016 -0700
Committer: Anthony Baker <abaker@apache.org>
Committed: Tue May 3 18:37:18 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19b9fe5a/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/19b9fe5a/geode-core/build.gradle
----------------------------------------------------------------------
diff --git a/geode-core/build.gradle b/geode-core/build.gradle
index 45051dc..a0bc46a 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,42 +172,18 @@ 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')}",
+      "Build-Date"        : new Date().format('yyyy-MM-dd HH:mm:ss Z'),
+      "Build-Platform"    : "${System.getenv('os.name')} ${System.getenv('os.version')} ${System.getenv('os.arch')}",
+      "Build-Java-Version": System.getenv('java.version'),
     ] as Properties
 
     propertiesFile.getParentFile().mkdirs();
     new FileOutputStream(propertiesFile).withStream { fos ->
-      props.store(fos, '')
+      props.plus(readScmInfo()).store(fos, '')
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19b9fe5a/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