diff --git a/jgiven-core/build.gradle b/jgiven-core/build.gradle index cee214e381..6e6273a343 100644 --- a/jgiven-core/build.gradle +++ b/jgiven-core/build.gradle @@ -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' } @@ -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' }