// 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_build_counter = System.getenv("build_counter") if(env_build_counter != null) { // This has been assigned by TeamCity, so use it if present println "Using version code $env_build_counter from environment (TeamCity)" return env_build_counter } 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 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 return "$env_environment" } else { // Building probably from IDE, so use "local" return "local" } } ext { VERSION_CODE=getVersionCode() VERSION_NAME=getVersionName() VERSION_ENVIRONMENT=getVersionEnvironment() }