buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "com.bmuschko:gradle-tomcat-plugin:2.2.4" } } subprojects { apply plugin: 'java' apply plugin: 'eclipse' repositories { mavenCentral() } dependencies { testCompile 'junit:junit:4.8.2' } version = '3.1.2' jar { manifest.attributes provider: 'EGIZ', 'Specification-Version': getCheckedOutGitCommitHash(), 'Implementation-Version': project.version } } def getCheckedOutGitCommitHash() { def gitFolder = "$projectDir/../.git/" def takeFromHash = 40 def head = new File(gitFolder + "HEAD").text.split(":") def isCommit = head.length == 1 if(isCommit) return head[0].trim().take(takeFromHash) def refHead = new File(gitFolder + head[1].trim()) refHead.text.trim().take takeFromHash }