mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-21 01:01:41 +00:00
26 lines
935 B
Groovy
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 |