ntzrmtthihu777 ntzrmtthihu777 - 1 year ago 105
Git Question

build.gradle versioning based on git

I'm a minecraft modder, and I use the ForgeGradle plugin to build my mods.

I'm currently attempting to setup a versioning scheme based on my git revisions and hash. Under arch linux's PKGBUILD system I would use:

pkgver() {
cd $_pkgbase
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"

which would end up with something along the lines of

I'm attempting with the following:

ext.revision = 'git rev-list --count HEAD'.execute()
ext.hash = 'git rev-parse --short HEAD'.execute()
version = "r${revision.text}.${hash.text}"

which gets me almost what I need,
; not sure how to get rid of the
in each portion of the version.
Gradle 2.0, suggestions?

Further investigation due to Peter Niederwieser's comment lead me to run build with the info flag, and it does seem newlines are getting stuck into the file name:

Executing task ':reobf' (up-to-date check took 0.004 secs) due to:
Output file build/libs/CreepyPastaCraft-1.7.x-r70
-universal.jar has changed.

Answer Source

Well, as Peter has declined to turn his comment into an answer, I shall answer my own question for the benefit of others looking to do the same:

ext.revision = 'git rev-list --count HEAD'.execute().text.trim()
ext.hash = 'git rev-parse --short HEAD'.execute().text.trim()
version = "r${revision}.${hash}"

This yeilds the same result as the bash expression in my question.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download