diff --git a/build.gradle b/build.gradle index 29ad727b..72bd47a9 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ buildscript { } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + classpath 'org.ajoberstar:gradle-git:0.10.1' } } @@ -25,9 +26,22 @@ apply plugin: 'maven-publish' sourceCompatibility = 1.8 targetCompatibility = 1.8 +import org.ajoberstar.grgit.Grgit + +def repo = Grgit.open(project.file('.')) +project.ext.gitHash = repo.log().find().abbreviatedId +def branchname = repo.branch.getCurrent().fullName +if (branchname.contains('HEAD')) { + branchname = System.getenv("GIT_BRANCH") +} +branchname = branchname.substring(branchname.lastIndexOf('/') + 1) + boolean dev = System.getenv("RELEASE") == null || System.getenv("RELEASE").equalsIgnoreCase("false") -version = "${mod_version}" +ext.buildnumber = 0 +project.buildnumber = System.getenv('BUILD_NUMBER') == null ? "CUSTOM" : System.getenv('BUILD_NUMBER') + +version = dev ? "${branchname}-${buildnumber}-${project.ext.gitHash}" : "${mod_version}.${buildnumber}" group = "team.chisel" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "Chisel"