Skip to content

Commit

Permalink
Merge pull request #1798 from TNG/fix/gradle-deprecation
Browse files Browse the repository at this point in the history
Fix/gradle deprecation
  • Loading branch information
l-1squared authored Dec 6, 2024
2 parents 491a294 + 06d0ad3 commit dacb560
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public enum ExecutionStatus {
FAILED,
ABORTED,
SOME_STEPS_PENDING
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public void can_create_an_output_folder() throws IOException {
assertThat(outputDir.list())
.contains("com.tngtech.jgiven.report.text.ResourceForPlainTextReportGeneratorTest.feature");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
}
],
"tagMap": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ private static void assertJAssumptionFailure() {
private static void junitAssumptionFailure() {
Assume.assumeTrue(false);
}
}
}

0 comments on commit dacb560

Please sign in to comment.