Repository: incubator-geode Updated Branches: refs/heads/develop 88da70259 -> c7024bd84
GEODE-151: Convert to use Gradle Git plugin The build was using the executable git command to populate version information, which created big blocks of Gradle code and could be unstable. All Git executable commands have been changed to use the Gradle Git plugin. If directory is not a valid Git workspace, then it will log a warning and use default values to populate version information. Tested with and without Git workspace Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/c7024bd8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/c7024bd8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/c7024bd8 Branch: refs/heads/develop Commit: c7024bd846e5075fe87b1b2b6c1707950241370b Parents: 88da702 Author: Mark Bretl <[email protected]> Authored: Mon Nov 16 10:44:50 2015 -0800 Committer: Mark Bretl <[email protected]> Committed: Mon Nov 16 12:16:58 2015 -0800 ---------------------------------------------------------------------- build.gradle | 13 +++++++++- gemfire-core/build.gradle | 59 +++++++----------------------------------- 2 files changed, 22 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c7024bd8/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index e3b1033..a186710 100755 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,15 @@ -apply plugin: 'wrapper' +buildscript { + repositories { + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath "org.ajoberstar:gradle-git:1.3.2" + } +} +apply plugin: 'wrapper' // Load all properties in dependency-version.properties as project properties, so all projects can read them Properties dependencyVersions = new Properties() @@ -25,6 +35,7 @@ allprojects { group = "org.apache.geode" + apply plugin: 'org.ajoberstar.grgit' apply plugin: 'idea' apply plugin: 'eclipse' http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c7024bd8/gemfire-core/build.gradle ---------------------------------------------------------------------- diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle index 80761ed..f03066f 100755 --- a/gemfire-core/build.gradle +++ b/gemfire-core/build.gradle @@ -99,55 +99,16 @@ task createVersionPropertiesFile { inputs.dir compileJava.destinationDir doLast { - new ByteArrayOutputStream().withStream { gitWorkspaceStream -> - def result = exec { - workingDir = "${projectDir}" - standardOutput = gitWorkspaceStream - ignoreExitValue = true - executable = "git" - args = ['rev-parse', '--is-inside-work-tree'] - } - ext.isGitWorkspace = gitWorkspaceStream.toString() - ext.isGitWorkspace = ext.isGitWorkspace.trim() - } - if ( isGitWorkspace.equalsIgnoreCase('true') ) { - new ByteArrayOutputStream().withStream { gitBranchStream -> - def result = exec { - workingDir = "${projectDir}" - 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 { - workingDir = "${projectDir}" - standardOutput = commitStream - executable = "git" - args = ['rev-parse', 'HEAD'] - } - ext.commitIdString = commitStream.toString() - ext.commitId = ext.commitIdString.trim() - } - - new ByteArrayOutputStream().withStream { sourceDateStream -> - def result = exec { - workingDir = "${projectDir}" - 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' + try { + def grgit = org.ajoberstar.grgit.Grgit.open() + 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') } @@ -168,7 +129,7 @@ task createVersionPropertiesFile { "Build-Java-Version": ext.jdkVersion, "Source-Date" : ext.sourceDate, "Source-Revision" : ext.commitId, - "Source-Repository" : ext.gitBranch + "Source-Repository" : ext.branch ] as Properties propertiesFile.getParentFile().mkdirs();
