Skip to content

Commit

Permalink
Add static fields for build date and commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
p3k committed Jun 15, 2024
1 parent 5de4616 commit efb7ad8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 4 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/helma/main/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@
*/
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;
Expand Down

0 comments on commit efb7ad8

Please sign in to comment.