Android gradle build: how to set global variables

To set a global variable

project.ext.set("variableName", value)

To access it from anywhere in the project:

project.variableName

For instance:

project.ext.set("newVersionName", versionString)

and then…

println project.newVersionName

For more information see: http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html

EDIT:
As commented by Dmitry, In new versions you can use the following shorthand:

project.ext.variableName = value

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)