mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 09:56:57 +00:00
Introduce -version
argument to display version
This commit is contained in:
parent
9fc18151c9
commit
a77ae0bc3c
16
build.gradle
16
build.gradle
@ -45,6 +45,14 @@ targetCompatibility = JavaVersion.VERSION_17
|
|||||||
group = 'xyz.grasscutters'
|
group = 'xyz.grasscutters'
|
||||||
version = '1.1.1-dev'
|
version = '1.1.1-dev'
|
||||||
|
|
||||||
|
def gitCommitHash = {
|
||||||
|
try {
|
||||||
|
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
|
||||||
|
} catch (e) {
|
||||||
|
return "GIT_NOT_FOUND"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sourceCompatibility = 17
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 17
|
targetCompatibility = 17
|
||||||
|
|
||||||
@ -97,6 +105,7 @@ application {
|
|||||||
mainClassName = 'emu.grasscutter.Grasscutter'
|
mainClassName = 'emu.grasscutter.Grasscutter'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Main-Class': 'emu.grasscutter.Grasscutter'
|
attributes 'Main-Class': 'emu.grasscutter.Grasscutter'
|
||||||
@ -113,6 +122,13 @@ jar {
|
|||||||
from('src/main/java') {
|
from('src/main/java') {
|
||||||
include '*.xml'
|
include '*.xml'
|
||||||
}
|
}
|
||||||
|
new File(projectDir, "src/generated/main/java/emu/grasscutter/BuildConfig.java").text = """
|
||||||
|
package emu.grasscutter;
|
||||||
|
public class BuildConfig {
|
||||||
|
public static final String VERSION = \"${version}\";
|
||||||
|
public static final String GIT_HASH = \"${gitCommitHash()}\";
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
destinationDir = file(".")
|
destinationDir = file(".")
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import emu.grasscutter.server.dispatch.DispatchServer;
|
|||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.tools.Tools;
|
import emu.grasscutter.tools.Tools;
|
||||||
import emu.grasscutter.utils.Crypto;
|
import emu.grasscutter.utils.Crypto;
|
||||||
|
import emu.grasscutter.BuildConfig;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -82,6 +83,9 @@ public final class Grasscutter {
|
|||||||
case "-gachamap" -> {
|
case "-gachamap" -> {
|
||||||
Tools.createGachaMapping(DATA("gacha_mappings.js")); exitEarly = true;
|
Tools.createGachaMapping(DATA("gacha_mappings.js")); exitEarly = true;
|
||||||
}
|
}
|
||||||
|
case "-version" -> {
|
||||||
|
System.out.println("Grasscutter version: " + BuildConfig.VERSION + "\nGit Hash: " + BuildConfig.GIT_HASH); exitEarly = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user