Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
41de6bd2
Commit
41de6bd2
authored
May 10, 2022
by
mingjun97
Committed by
Melledy
May 11, 2022
Browse files
Make `injectGitHash` as a task
parent
570635ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
41de6bd2
...
@@ -45,13 +45,6 @@ targetCompatibility = JavaVersion.VERSION_17
...
@@ -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 {
...
@@ -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 {
...
@@ -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"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment