From 79de641fe8cb9109024cc9cee89b8e872a916a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Sun, 30 Jun 2024 20:41:02 +0100 Subject: [PATCH] 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 --- app/build.gradle | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ea26b826d..d27d2c5fc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 }