Gradle Variables and Properties: Difference between revisions
Line 26: | Line 26: | ||
===gradle.properties Files=== | ===gradle.properties Files=== | ||
<tt>gradle.properties</tt> can be used to define [[Gradle_Variables_and_Properties#Properties|properties]] for the build. <tt>gradle.properties</tt> files can be placed either in Gradle user home directory (~/.gradle/gradle.properties) or in the project root directory. If both files are present, their content is merged and the configuration that comes from the user home directory takes precedence over the configuration that comes from the project root directory. If a command line -D''property-name''=... is specified, the value overrides the value read from the property files, if any. | |||
Form a security perspective, it makes sense to use the user home directory if the project is checked into a repository and we do not want to maintain sensitive information in that file. | |||
<syntaxhighlight lang='groovy'> | |||
someUser=someuser | |||
somePassword=somepassword | |||
</syntaxhighlight> | |||
====User Home==== | ====User Home==== |
Revision as of 16:58, 23 May 2018
External
Internal
Overview
Concepts
System Properties
Gradle Properties
Project Properties
Where are These Properties Provided
These configuration methods are listed in the descending order of their precedence, with the highest precedence at the top. The first one encountered wins.
Command Line Flags
Command line flags have precedence over properties and environment variables with the same effect. See:
Command Line Property Definitions
gradle.properties Files
gradle.properties can be used to define properties for the build. gradle.properties files can be placed either in Gradle user home directory (~/.gradle/gradle.properties) or in the project root directory. If both files are present, their content is merged and the configuration that comes from the user home directory takes precedence over the configuration that comes from the project root directory. If a command line -Dproperty-name=... is specified, the value overrides the value read from the property files, if any.
Form a security perspective, it makes sense to use the user home directory if the project is checked into a repository and we do not want to maintain sensitive information in that file.
someUser=someuser
somePassword=somepassword