Where is environment variable System.env.CUSTOM_BUILDTOOLS in the below given build.gradle file defined

I came across few examples for latest gradle build tools and android studio at link :

http://tools.android.com/tech-docs/new-build-system : gradle-samples-0.14.0.zip

In all the examples the build.gradle contained a line : System.env.CUSTOM_BUILDTOOLS I am unable to find the source where this variable is defined Check the below mentioned build.gradle example

ext {

buildToolsVersion = System.env.CUSTOM_BUILDTOOLS != null ? System.env.CUSTOM_BUILDTOOLS : ‘20.0.0’ }

buildscript {

def gradleVersion = System.env.CUSTOM_GRADLE != null ? System.env.CUSTOM_GRADLE : ‘0.14.0’

repositories {

if (System.env.CUSTOM_REPO != null) {

maven { url System.env.CUSTOM_REPO }

} else {




dependencies {

classpath “com.android.tools.build:gradle:$gradleVersion”

} }

Apparently this build script allows developers to override some defaults using environment variables (which are defined outside Gradle). It’s by no means mandatory to have such a build script. If you want to know more about this particular build script, I recommend to ask the authors on the Android tools list.

ok…So it means that if there is no variable named as CUSTOM_BUILDTOOLS defined in the system environment variables then System.env.CUSTOM_BUILDTOOLS == null would evaluate as true. The writer of this script has just assumed that if there is any variable defined as CUSTOM_BUILDTOOLS then use it or use given value?


Got it. Thank you