mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-24 03:43:01 +08:00
Make injectGitHash
as a task
This commit is contained in:
parent
570635ea02
commit
41de6bd229
34
build.gradle
34
build.gradle
@ -45,13 +45,6 @@ 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
|
||||||
@ -122,13 +115,6 @@ jar {
|
|||||||
from('src/main/java') {
|
from('src/main/java') {
|
||||||
include '*.xml'
|
include '*.xml'
|
||||||
}
|
}
|
||||||
new File(projectDir, "src/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(".")
|
||||||
}
|
}
|
||||||
@ -242,6 +228,26 @@ javadoc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task injectGitHash {
|
||||||
|
doLast {
|
||||||
|
def gitCommitHash = {
|
||||||
|
try {
|
||||||
|
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
|
||||||
|
} catch (e) {
|
||||||
|
return "GIT_NOT_FOUND"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new File(projectDir, "src/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()}\";
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
dependsOn "generateProto"
|
dependsOn "generateProto"
|
||||||
|
dependsOn "injectGitHash"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user