Skip to content
Snippets Groups Projects
Commit 466902b3 authored by dgelessus's avatar dgelessus
Browse files

Reimplement processResources to avoid Gradle deprecation warnings

Code adapted from prob2_ui.
parent 4c5a8071
No related branches found
No related tags found
No related merge requests found
...@@ -49,21 +49,19 @@ tasks.withType(JavaCompile) { ...@@ -49,21 +49,19 @@ tasks.withType(JavaCompile) {
options.encoding = SOURCE_ENCODING options.encoding = SOURCE_ENCODING
} }
def readCurrentGitCommit() { final firstLineOfProcessOutput = {ExecOutput execOutput ->
def proc = ["git", "rev-parse", "HEAD"].execute(null, project.projectDir) return execOutput.standardOutput.asText.map {it.split('\n')[0]}
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 currentGitCommit = readCurrentGitCommit()
processResources { processResources {
inputs.property("project.version", project.version) inputs.property("version", project.version)
inputs.property("currentGitCommit", currentGitCommit) inputs.property("currentGitCommit", firstLineOfProcessOutput(providers.exec {
executable = "git"
args = ["rev-parse", "HEAD"]
}))
filesMatching("de/prob2/jupyter/build.properties") { filesMatching("de/prob2/jupyter/build.properties") {
expand(version: project.version, commit: readCurrentGitCommit()) expand(version: inputs.properties["version"], commit: inputs.properties["currentGitCommit"])
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment