Files
PhotonVision/photon-server/versioningHelper.gradle
Matt 5110e5c9f2 Add github-based automatic versioning (#42)
This applies to the shadowjar and adds the PhotonVersion class
2020-07-18 02:22:42 -04:00

26 lines
935 B
Groovy

gradle.allprojects {
ext.getCurrentVersion = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim().toLowerCase()
}
}
task writeCurrentVersionJava {
File versionFile = new File("src/main/java/org/photonvision/PhotonVersion.java")
versionFile.delete()
versionFile << "package org.photonvision;\n" +
"\n" +
"/*\n" +
" * Autogenerated file! Do not manually edit this file. This version is regenerated\n" +
" * any time the publish task is run, or when this file is deleted.\n" +
" */\n\n" +
"public class PhotonVersion {\n" +
String.format(" public static final String versionString = \"%s\";\n", getCurrentVersion()) +
"}"
}
build.dependsOn writeCurrentVersionJava