Add static fields for build date and commit hash

This commit is contained in:
Tobi Schäfer 2024-06-15 22:43:26 +02:00
parent 5de4616df0
commit efb7ad89b3
Signed by: tobi
GPG key ID: 91FAE6FE2EBAC4C8
2 changed files with 11 additions and 10 deletions

View file

@ -155,26 +155,21 @@ installDist {
}
task processSource(type: Sync) {
def date = new Date().format("d MMM yyyy")
def gitOutput = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe'
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = gitOutput
errorOutput = new ByteArrayOutputStream()
ignoreExitValue = true
}
def description = date
def tag = gitOutput.toString().trim()
// TODO: Implement extended description in Java code
if (tag) description = "$tag; $description"
from 'src'
filter {
line -> line.replaceAll('__builddate__', date)
line -> line
.replaceAll('__builddate__', new Date().format("d MMM yyyy"))
.replaceAll('__commithash__', gitOutput.toString().trim())
} into "${project.buildDir}/src"
}

View file

@ -36,7 +36,13 @@ import helma.util.ResourceProperties;
*/
public class Server implements Runnable {
// version string
public static final String version = "🐜 (__builddate__)";
public static final String version = "🐜";
// build date
public static final String buildDate = "__builddate__";
// commit hash
public static final String commitHash = "__commithash__";
// static server instance
private static Server server;