Add github-based automatic versioning (#42)

This applies to the shadowjar and adds the PhotonVersion class
This commit is contained in:
Matt
2020-07-17 23:22:42 -07:00
committed by GitHub
parent 1c5712aa39
commit 5110e5c9f2
3 changed files with 32 additions and 1 deletions

1
.gitignore vendored
View File

@@ -124,3 +124,4 @@ New client/photon-client/*
photon-server/build
photon-server/photon-vision
photon-server/src/main/resources/web
photon-server/src/main/java/org/photonvision/PhotonVersion.java

View File

@@ -6,10 +6,12 @@ plugins {
id "jacoco"
}
apply from: 'versioningHelper.gradle'
mainClassName = 'org.photonvision.Main'
group 'org.photonvision'
version '2020.6.1'
version getCurrentVersion()
sourceCompatibility = 11
@@ -129,6 +131,8 @@ spotless {
java {
target "src/*/java/org/**/*.java"
licenseHeaderFile "$rootDir/LicenseHeader.txt"
targetExclude("src/main/java/org/photonvision/PhotonVersion.java")
}
}

View File

@@ -0,0 +1,26 @@
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