mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 13:54:37 +01:00
Show git hash when starting the server
This commit is contained in:
20
build.gradle
20
build.gradle
@@ -102,6 +102,8 @@ application {
|
||||
}
|
||||
|
||||
jar {
|
||||
dependsOn 'injectGitHash'
|
||||
|
||||
exclude '*.proto'
|
||||
|
||||
manifest {
|
||||
@@ -145,6 +147,24 @@ eclipse {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('injectGitHash') {
|
||||
def gitCommitHash = {
|
||||
try {
|
||||
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
|
||||
} catch (ignored) {
|
||||
return 'GIT_NOT_FOUND'
|
||||
}
|
||||
}
|
||||
|
||||
new File(project.projectDir.getAbsolutePath() + '/src/main/java/emu/lunarcore/BuildConfig.java').text = """
|
||||
package emu.lunarcore;
|
||||
|
||||
public final class BuildConfig {
|
||||
public static final String GIT_HASH = \"${gitCommitHash()}\";
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
task updateProto {
|
||||
group 'Build'
|
||||
description 'Cleans generated proto folder and regenerates protos'
|
||||
|
||||
Reference in New Issue
Block a user