Book Image

Mastering Gradle

Book Image

Mastering Gradle

Overview of this book

Table of Contents (17 chapters)
Mastering Gradle
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Property management


We cannot make a software available on different operating systems, or different environments without configuring it dynamically. One approach to configure software is by using the properties file or environment properties. The following are the different ways Gradle provides to configure properties to build.gradle:

  • ext closure

  • gradle.properties

  • Command line

  • Custom properties file

ext closure

We saw many examples in Chapter 3, Managing Task, of adding custom properties to a project using the ext closure. Thus, we will not discuss the topic in this chapter.

gradle.properties

Gradle provides a default mechanism of reading the properties file using gradle.properties. You can add the gradle.properties file in any of the following locations:

  • <USER_HOME>/.gradle: gradle.properties defined under this directory would be accessible to all the projects. You can use this file to define global properties and you can access these properties using $project.<propertyname>. If...