Q: Gradle read environment specific values from properties.xml I am trying to manage version number for each environment differently from gradle using productFlavors. I have the following in my properties.xml file
<resources>
    <integer name="version.code">100</integer>
    <string name="version.name">1.0.1</string>
</resources>

and I wrote the following in my build.gradle file. I expected it to act like switch-case however the following gradle sync error showed me the opposite.
productFlavors {

    String path = "res/values/properties.xml";

    prd {
        applicationId "com.company.appname"
        path = "../prd/" + path;
    }

    tst {
        applicationId "com.company.appname.tst"
        path = "../tst/" + path;
    }

    dvl {
        applicationId "com.company.appname.dvl"
        path = "../dvl/" + path;
    }
    qa {
        applicationId "com.company.appname.qa"
        path = "../qa/" + path;
    }

    Properties props = new Properties()
    props.load(new FileInputStream(path))

    if (propFile.canRead()){
        props.load(new FileInputStream(propFile))

        if (props!=null && props.containsKey('version.code') && props.containsKey('version.name')) {
            versionCode props.getProperty('version.code')
            versionName props.getProperty('version.name')
        }
    }

}


..\qa..\dvl..\tst..\prd\res\values\properties.xml (The system cannot find the path specified)

How can I read environment specific version.code and version.name from build.gradle?
