Apologies in advance for my ignorance. I\'m very new to gradle.
My is goal is to have some task in my build.gradle file, wherein a file \'version.txt\' is created in
The example you're referring to is almost correct. With a couple of minor tweaks it works as expected:
import java.text.SimpleDateFormat
import org.ajoberstar.grgit.Grgit
plugins {
id "org.ajoberstar.grgit" version "1.7.2"
}
version = 1.0
task versionTxt() {
doLast {
new File(projectDir, "version.txt").text = """
Version: $version
Revision: ${grgit.head().abbreviatedId}
Buildtime: ${new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())}
Application-name: foobarbaz app
"""
}
}
Run gradle versionTxt
to get the desired output.