I am working on an Android library (aar) project. The project contains a README.md file which in turn contains these lines:
... declare library dependency:
Gradle: `compile 'com.acme:mylibrary:1.0.0@aar'`
My gradle.properties file contains:
VERSION_NAME=1.0.0
The problem is that currently I have to keep two files manually in sync. What I would like to do is keep the VERSION_NAME property and substitute it's value into README.md
If you have some pattern to find out where you used the version number it could be as easy as creating a tasks and replacing text based on a regex.
Something like:
task replaceVersionInREADME << {
// Maven
ant.replaceregexp(match:'<version>([0-9\\.]+)</version>', replace:"<version>${version}</version>", flags:'g', byline:true) {
fileset(dir: '.', includes: 'README.md')
}
// Gradle
ant.replaceregexp(match:'com\\.acme\\:mylibrary\\:([0-9\\.]+)', replace:"com.acme:mylibrary:${version}", flags:'g', byline:true) {
fileset(dir: '.', includes: 'README.md')
}
}
Change the regex as you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With