// version.gradle // // This depends on ext.rootPath = path to /android folder in repository // It can be a relative path. Gradle does not appear to support relative // paths from included scripts. // def getVersionCode = { -> String env_version_major = System.getenv("VERSION_MAJOR") String env_version_minor = System.getenv("VERSION_MINOR") String env_version_patch = System.getenv("VERSION_PATCH") if(env_version_patch != null && env_version_minor != null && env_version_patch != null) { // Version code is, for 14.1.33: 1410033. This supports up to 9999 builds for a // given major.minor version. We only support up to 9 minor versions for a given // major version but at present we are not using minor versions at all. Integer version_code = env_version_major.toInteger() * 100000 + env_version_minor.toInteger() * 10000 + env_version_patch.toInteger() println "Using version code " + version_code return version_code } // Probably building from IDE println "Using fixed version code 100" return 100 } def getVersionName = { -> String env_version = System.getenv("VERSION_WITH_TAG") if (env_version != null) { // If building from script, we have build number in VERSION_WITH_TAG println "Using build $env_version from VERSION_WITH_TAG" return "$env_version" } else { // Building probably from IDE, so let's use VERSION.md and TIER.md directly // This is a close match with VERSION_WITH_TAG, except that 'stable' tier // is not normally included with VERSION_WITH_TAG String version_md = file("$rootPath/../VERSION.md").text.trim() String tier_md = file("$rootPath/../TIER.md").text.trim() println "Using build $version_md-$tier_md-local from project VERSION.md/TIER.md" return "$version_md-$tier_md-local" } } def getVersionEnvironment = { -> String env_environment = System.getenv("VERSION_ENVIRONMENT") if (env_environment != null) { // If building from script, we have build number in VERSION_ENVIRONMENT println "Using $env_environment from VERSION_ENVIRONMENT" return "$env_environment" } else { // Building probably from IDE, so use "local" println "Using local environment" return "local" } } ext { VERSION_CODE=getVersionCode() VERSION_NAME=getVersionName() VERSION_ENVIRONMENT=getVersionEnvironment() }