Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use gradle.properties vs. settings.gradle?

A gradle build has three files

  • build.gradle that defines the build configuration scripts
  • gradle.properties
  • settings.gradle

Questions

  • What are differences between settings.gradle & gradle.properties?
  • When should a settings be put in settings.gradle vs. gradle.properties?
like image 706
ams Avatar asked Jul 29 '17 10:07

ams


People also ask

What is the purpose of Gradle properties?

properties. This is optional, its main purpose is to provide startup options to use for running gradle itself, e.g. These values can be overridden by a file USER_HOME/.

Do I need settings Gradle?

The framework requires the existence of the settings. gradle in a multi-project build, while it's optional for a single-project build.

What is the use of settings Gradle file?

gradle file, located in each project / module / directory, allows you to configure build settings for the specific module it is located in.

Where should Gradle properties go?

Actually there are 3 places where gradle. properties can be placed: Under gradle user home directory defined by the GRADLE_USER_HOME environment variable, which if not set defaults to USER_HOME/. gradle.


1 Answers

settings.gradle

The settings.gradle file is a Groovy script, just like the build.gradle file. Only one settings.gradle script will be executed in each build (in comparison to multiple build.gradle scripts in multi-project builds). The settings.gradle script will be executed before any build.gradle script and even before the Project instances are created. Therefore, it is evaluated against a Settings object. With this Settings object you can add subprojects to your build, modify the parameters from the command line (StartParameter), and access the Gradle object to register lifecycle handlers. As a consequence, use settings.gradle if your settings are build-related and not necessarily project-related or require logic before possible subprojects are included.

gradle.properties

The gradle.properties file is a simple Java Properties file that only gains a special role by being automatically included into the scope of the Project object (as so-called 'project properties'). It's a simple key-value store that only allows string values (so you need to split lists or arrays by yourself). You can put gradle.properties files to these locations:

  • directly in the project directory (for project-related values)
  • in the user home .gradle directory (for user- or environment-related values)
like image 52
Lukas Körfer Avatar answered Oct 06 '22 00:10

Lukas Körfer