How to read latest property in property file that

2019-07-17 20:08发布

问题:

For my Android project I have configured the defaultConfig such that it gets the versionName for the AndroidManifest.xml in the generated apk from a version property in ./gradle.properties. This works great. Here is snippet from build.gradle:

android {
  ....
  defaultConfig {
    minSdkVersion 16    //4.1.2 
    targetSdkVersion 19 //4.4 KitKat

    versionName = version  //Read from gradle.properties
    ...
}

The problems is that when I use the townsfolk/gradle-release plugin that plugin updates the property in ./gradle.properties (bumps it up to the next release name) earlier in the execution.

In this scenario the versionName that is read is from the original ./gradle.properties file before it was modified by gradle-release plugin.

How can I force the reading of the property file just in time to pick up the latest property settings? TIA for your help