Skip to content

Commit

Permalink
fix(Gradle): Replace deprectated exec statement for jgiven-core
Browse files Browse the repository at this point in the history
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
  • Loading branch information
l-1squared committed Dec 3, 2024
1 parent d88d026 commit e475c7c
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions jgiven-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,32 @@ sourceSets {
}
}

def buildNumber = getGitHash()
def buildNumber = 'git rev-parse --short HEAD'.execute().text.trim()


println 'BUILD SHA1: ' + buildNumber

processResources {
expand(
'version': project.version,
'buildNumber': buildNumber
'version': project.version,
'buildNumber': buildNumber
)
}

files { file("src/main/translations").listFiles() }.collect {
def pkg=it.getName().split("\\.")[0]
def pkg = it.getName().split("\\.")[0]

def props = new Properties()
it.withInputStream { props.load(it) }
props.pkg=pkg
def taskName = pkg+'Translation'
props.pkg = pkg
def taskName = pkg + 'Translation'

tasks.create(name: taskName, type: Copy) {
tasks.register(taskName, Copy) {
from 'src/main/templates'
into generatedSourceDir + "/com/tngtech/jgiven/lang/" + pkg
rename("Stage.template",props.stage_class+".java")
rename("SimpleScenarioTestBase.template",props.simple_scenario_test_base_class+".java")
rename("ScenarioTestBase.template",props.scenario_test_base_class+".java")
rename("Stage.template", props.stage_class + ".java")
rename("SimpleScenarioTestBase.template", props.simple_scenario_test_base_class + ".java")
rename("ScenarioTestBase.template", props.scenario_test_base_class + ".java")
expand(props)
filteringCharset = 'UTF-8'
}
Expand All @@ -58,15 +59,6 @@ files { file("src/main/translations").listFiles() }.collect {
javadoc.dependsOn += taskName
}

/**
* Copied from https://stackoverflow.com/questions/28498688/gradle-script-to-autoversion-and-include-the-commit-hash-in-android
* Author: Paul
*/
def getGitHash() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
tasks.register("runShellCommand", Exec){
commandLine 'git', 'rev-parse', '--short', 'HEAD'
}

0 comments on commit e475c7c

Please sign in to comment.