mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-01 02:41:42 +00:00
Add github-based automatic versioning (#42)
This applies to the shadowjar and adds the PhotonVersion class
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
photon-server/versioningHelper.gradle
Normal file
26
photon-server/versioningHelper.gradle
Normal 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
|
||||
Reference in New Issue
Block a user