Skip to content

Commit

Permalink
Move dependency on GrGit to buildSrc module
Browse files Browse the repository at this point in the history
(no longer requiring the Gradle plugin, just the GrGit class)
  • Loading branch information
tsjensen committed Sep 3, 2017
1 parent eabcaa0 commit a147ea4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 2 additions & 4 deletions build.gradle
Expand Up @@ -28,14 +28,14 @@ plugins {
id 'idea';
id 'maven-publish';
id 'com.jfrog.bintray' version '1.2';
id 'org.ajoberstar.grgit' version '2.0.0';
id 'com.dorongold.task-tree' version '1.3';
}

repositories {
jcenter()
}


import com.thomasjensen.checkstyle.addons.build.BuildUtil;
import com.thomasjensen.checkstyle.addons.build.ClasspathBuilder;
import com.thomasjensen.checkstyle.addons.build.DependencyConfig;
Expand All @@ -45,7 +45,6 @@ import com.thomasjensen.checkstyle.addons.build.TaskCreator;
import com.thomasjensen.checkstyle.addons.build.VersionWrapper;
import com.thomasjensen.checkstyle.addons.build.tasks.JavadocTask;
import com.thomasjensen.checkstyle.addons.build.tasks.SiteTask;
import org.ajoberstar.grgit.Grgit;
import org.apache.tools.ant.filters.ReplaceTokens;


Expand Down Expand Up @@ -74,9 +73,8 @@ ext {
sqPackage = 'com/thomasjensen/checkstyle/addons/sonarqube';
checksPackage = 'com/thomasjensen/checkstyle/addons/checks';
website = 'http://checkstyle-addons.thomasjensen.com/';
gitRepo = Grgit.open();
gitHash = gitRepo.head().id;
buildUtil = new BuildUtil(project);
gitHash = buildUtil.currentGitCommitHash();
}


Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle
Expand Up @@ -28,6 +28,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8;

dependencies {
compile group: 'com.github.jengelman.gradle.plugins', name: 'shadow', version: '1.2.4';
compile group: 'org.ajoberstar', name: 'grgit', version: '2.0.0';
compileOnly group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1';
compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1';
testCompile group: 'junit', name: 'junit', version: '4.12';
Expand Down
Expand Up @@ -21,6 +21,7 @@
import javax.annotation.Nullable;

import groovy.lang.Closure;
import org.ajoberstar.grgit.Grgit;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.Task;
Expand Down Expand Up @@ -213,4 +214,18 @@ public Void call()
}
});
}



/**
* Determine the git commit hash of the most recent commit in this repo.
*
* @return the hash
*/
public String currentGitCommitHash()
{
try (Grgit gitRepo = Grgit.open()) {
return gitRepo.head().getId();
}
}
}

0 comments on commit a147ea4

Please sign in to comment.