Skip to content

Instantly share code, notes, and snippets.

@tgkprog
Last active August 24, 2017 18:15
Show Gist options
  • Save tgkprog/4923284aacd68480d232b42c1239c529 to your computer and use it in GitHub Desktop.
Save tgkprog/4923284aacd68480d232b42c1239c529 to your computer and use it in GitHub Desktop.
Gradle build with with code to put the git revision and other information using org.ajoberstar.grgit
plugins {
id "org.ajoberstar.grgit" version "1.5.1-rc.3"
}
apply plugin: 'java'
repositories {
///....
}
dependencies {
//...
}
import java.text.SimpleDateFormat
import org.ajoberstar.grgit.Grgit
version = 1.2
task versionTxt() << {
def file = new File("$projectDir/build/classes/java/main/version.txt")
file.createNewFile()
file.text = """
Version: $version
Revision: ${Grgit.open(dir: '.').head().id}
Branch : ${Grgit.open(dir: '.').branch.getCurrent().fullName}
Buildtime: ${new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())}
Application-name: Wibmo wallet Commons
"""
}
jar.dependsOn versionTxt
jar{
from ('build/classes/java/main'){
include "$projectDir/build/classes/version.txt"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment