Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helpers for build gradle
buildscript {
ext.versionMajor = 1
ext.versionMinor = 0
ext.versionPatch = 0
ext.generateVersionCode = {
return ext.minSdkVersion * 10000000 + ext.versionMajor * 10000 + ext.versionMinor * 100 + ext.versionPatch
}
ext.generateVersionName = {
return "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}"
}
ext.getLocalProperty = { property, ifnull ->
def propertiesFile = file("$rootProject.projectDir/local.properties")
if (propertiesFile.exists())
if (propertiesFile.canRead()) {
def properties = new Properties()
propertiesFile.withDataInputStream { properties.load(it) }
return properties.getProperty(property, ifnull)
} else
throw new GradleException("Could not read local.properties")
else
throw new GradleException("Could not find local.properties")
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.