1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-24 17:45:50 +01:00

Use provider.exec for process execution during build

Required to enable configuration-cache, as per https://docs.gradle.org/8.8/userguide/configuration_cache.html#config_cache:requirements:external_processes
This commit is contained in:
José Rebelo 2024-06-30 20:41:02 +01:00
parent d7242c1f12
commit 79de641fe8

View File

@ -11,29 +11,25 @@ tasks.withType(Test) {
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
standardOutput = stdout
}
return Integer.valueOf(stdout.toString().trim())
def commitCount = providers.exec {
commandLine('git', 'rev-list', 'HEAD', '--count')
}.standardOutput.asText.get().trim()
return Integer.valueOf(commitCount)
} catch (ignored) {
return null
}
}
def buildGitChangelog = {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '--pretty=format:%h %s'
standardOutput = stdout
}
def allCommits = providers.exec {
commandLine('git', 'log', '--pretty=format:%h %s')
}.standardOutput.asText.get()
def commitVersionCode = getVersionCode()
def includedCommits = 0
def changelogNode = new Node(null, 'changelog')
stdout.toString().trim().eachLine { line ->
allCommits.trim().eachLine { line ->
if (includedCommits > 100) {
return true;
}
@ -55,12 +51,9 @@ def buildGitChangelog = {
def getGitHashShort = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
return providers.exec {
commandLine('git', 'rev-parse', '--short', 'HEAD')
}.standardOutput.asText.get().trim()
} catch (ignored) {
return null
}