Sorry if this is obvious, I'm new to Gradle and I'd like to include the latest git commit tag in my builds.
So far I have this task that simply outputs the string I want to save.
tasks.register<Exec>("get-git-latest") {
executable("git")
args("log", "--oneline", "-1", "--format=format:%h", ".")
}
Ideally I'd like to get this output into a variable that can be reused by other Gradle tasks, what is the best way to do this with Kotlin DSL? Any suggestions are welcome.
Upon revisitng the question that @aSemy linked, I was able to get the value into a variable in my Kotlin DSL like so:
val gitLatestCommit: String = ByteArrayOutputStream().use { outputStream ->
project.exec {
executable("git")
args("log", "--oneline", "-1", "--format=format:%h", ".")
standardOutput = outputStream
}
outputStream.toString()
}
I still need to figure out how to inject this into certain property files, but this is a great start. Thank You.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.