forked from Upstream/Velocitab
build: improve resiliency on uncloned build
This commit is contained in:
parent
9c04513ee9
commit
3a3f42f489
22
build.gradle
22
build.gradle
@ -55,9 +55,12 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
def tokenMap = rootProject.ext.properties
|
||||||
|
tokenMap.merge("grgit",'',(s, s2) -> s)
|
||||||
filesMatching(['**/*.json', '**/*.yml']) {
|
filesMatching(['**/*.json', '**/*.yml']) {
|
||||||
filter ReplaceTokens as Class, beginToken: '${', endToken: '}',
|
filter ReplaceTokens as Class, beginToken: '${', endToken: '}',
|
||||||
tokens: rootProject.ext.properties
|
tokens: rootProject.ext.properties
|
||||||
|
tokens: tokenMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,15 +172,20 @@ tasks {
|
|||||||
|
|
||||||
@SuppressWarnings('GrMethodMayBeStatic')
|
@SuppressWarnings('GrMethodMayBeStatic')
|
||||||
def versionMetadata() {
|
def versionMetadata() {
|
||||||
// Get if there is a tag for this commit
|
// Require grgit
|
||||||
|
if (grgit == null) {
|
||||||
|
return '-unknown'
|
||||||
|
}
|
||||||
|
|
||||||
|
// If unclean, return the last commit hash with -indev
|
||||||
|
if (!grgit.status().clean) {
|
||||||
|
return '-' + grgit.head().abbreviatedId + '-indev'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise if this matches a tag, return nothing
|
||||||
def tag = grgit.tag.list().find { it.commit.id == grgit.head().id }
|
def tag = grgit.tag.list().find { it.commit.id == grgit.head().id }
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
return '-' + grgit.head().abbreviatedId
|
||||||
// Otherwise, get the last commit hash and if it's a clean head
|
|
||||||
if (grgit == null) {
|
|
||||||
return '-' + System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown'
|
|
||||||
}
|
|
||||||
return '-' + grgit.head().abbreviatedId + (grgit.status().clean ? '' : '-indev')
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user