Dynamically generate a configuration which can be loaded by `./gradlew run`

This commit is contained in:
R. Tyler Croy 2016-12-18 10:30:21 -08:00
parent ac6907c5f1
commit 13dc8672cf
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
2 changed files with 18 additions and 1 deletions

View File

@ -36,3 +36,20 @@ dependencies {
// 'test.useTestNG()' to your build script.
testCompile 'junit:junit:4.12'
}
task generateExampleYaml {
def outputFile = "${buildDir}/httpwizard.example.yml"
group 'Build'
description "Generate ${outputFile} for running the app"
doLast {
file(outputFile).text = """---
appVersion: "${project.version}-${grgit.head().abbreviatedId}"
"""
}
outputs.file file(outputFile)
}
run {
args 'server', "${buildDir}/httpwizard.example.yml"
dependsOn generateExampleYaml
}

View File

@ -28,5 +28,5 @@ import org.hibernate.validator.constraints.NotEmpty
*/
class HttpWizardConfiguration extends Configuration {
@NotEmpty
private String appVersion
String appVersion
}