Skip to content

Instantly share code, notes, and snippets.

@paristote
Created January 25, 2016 16:33
Show Gist options
  • Save paristote/a0aa8861b57745b01d68 to your computer and use it in GitHub Desktop.
Save paristote/a0aa8861b57745b01d68 to your computer and use it in GitHub Desktop.
Gradle build snippets

Load a properties file in the build

Properties props = new Properties()
try {
    props.load(file('file.properties').newDataInputStream())
} catch (Exception ex) {
    throw new GradleException("Missing file.properties file.");
}

Configure a BuildConfig constant from a property

buildTypes {
        debug {
            buildConfigField "String", "KEY", "\"${props.getProperty("key")}\""
        }
        release {}
    }

Get system property

System.env.PROP_KEY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment