From 466902b359d02c447c219290b0e52f58f8dc86ff Mon Sep 17 00:00:00 2001 From: dgelessus <dgelessus@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:59:17 +0100 Subject: [PATCH] Reimplement processResources to avoid Gradle deprecation warnings Code adapted from prob2_ui. --- build.gradle | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 5101192..c8bc98a 100644 --- a/build.gradle +++ b/build.gradle @@ -49,21 +49,19 @@ tasks.withType(JavaCompile) { options.encoding = SOURCE_ENCODING } -def readCurrentGitCommit() { - def proc = ["git", "rev-parse", "HEAD"].execute(null, project.projectDir) - def exitCode = proc.waitFor() - if (exitCode != 0) { - throw new IllegalStateException("git rev-parse command exited with status code ${exitCode}:\n" + proc.err.readLines().join("\n")) - } - return proc.in.readLines()[0] +final firstLineOfProcessOutput = {ExecOutput execOutput -> + return execOutput.standardOutput.asText.map {it.split('\n')[0]} } -final currentGitCommit = readCurrentGitCommit() processResources { - inputs.property("project.version", project.version) - inputs.property("currentGitCommit", currentGitCommit) + inputs.property("version", project.version) + inputs.property("currentGitCommit", firstLineOfProcessOutput(providers.exec { + executable = "git" + args = ["rev-parse", "HEAD"] + })) + filesMatching("de/prob2/jupyter/build.properties") { - expand(version: project.version, commit: readCurrentGitCommit()) + expand(version: inputs.properties["version"], commit: inputs.properties["currentGitCommit"]) } } -- GitLab