Search

Dark theme | Light theme

October 2, 2015

Gradle Goodness: Setting Global Properties For All Gradle Builds

To define project properties outside the Gradle build file, we can define them in a file gradle.properties in our project directory. If we want to define property values that are used by all Gradle builds we can create a file gradle.properties in the GRADLE_USER_HOME directory. By default this is in the USER_HOME/.gradle directory.

In the following example gradle.properties file we assign values to some properties that can be used in all Gradle builds we run on our computer. We store the file in USER_HOME/.gradle.

# Bintray username and password.
bintrayUser=mrhaki
bintrayPasword={secret}

# Enable Gradle daemon for all builds.
org.gradle.daemon=true

In the following example build file we simply display the values for the bintrayUser and bintrayPoassword global properties:

// File: build.gradle
task showBintrayProps {
    doLast {
        println "Bintray user/password: ${bintrayUser}/${bintrayPassword}"
    }
}

Written with Gradle 2.7.