Last active
May 14, 2018 22:55
-
-
Save crc83/6d3601b22bae0f8e92b1d8539b0a670b to your computer and use it in GitHub Desktop.
update property in properties file from gradle script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void writeVersion(File file, String key, version) { | |
if (!file.file) { | |
project.ant.echo(file: file, message: "$key=$version") | |
} else { | |
// we use replace here as other ant tasks escape and modify the whole file | |
project.ant.replaceregexp(file: file, byline: true) { | |
regexp(pattern: "^(\\s*)$key((\\s*[=|:]\\s*)|(\\s+)).+\$") | |
substitution(expression: "\\1$key\\2$version") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment