Where to put the gradle.properties file

I follow Artifactory 1 minute setup . I have Artifactory and it works on my localhost, and now I'm trying to integrate it with Intellij / Gradle.

Artifactory webapp gives the gradle.properties and build.gradle , so I'm trying to start by adding them to my IntelliJ project. However, I do not know where to put the gradle.properties file.

I tried to copy the contents of gradle.properties (key = value pairs) to gradle/wrapper/gradle-wrapper.properties , unfortunately this does not make the keys available in the build.gradle file. Any ideas?

+55
intellij-idea artifactory gradle
May 19 '15 at 18:52
source share
2 answers

Gradle looks for gradle.properties files in the following places:

  • in the project build directory (your build script is located there)
  • in dir subproject
  • in the gradle user’s house (defined by the GRADLE_USER_HOME environment GRADLE_USER_HOME , which, if not set, defaults to USER_HOME/.gradle )

Properties from one file override properties from the previous ones (thus, the file in the user's home storage takes precedence over the others, and the file in the subproject takes precedence over the file in the project root).

Link: https://gradle.org/docs/current/userguide/build_environment.html

+86
May 19 '15 at 18:57
source share

There are actually 3 places where gradle.properties can be placed:

  • In gradle, the user's home directory, defined by the GRADLE_USER_HOME environment GRADLE_USER_HOME , which, if not set by default, USER_HOME / .gradle
  • myProject2 Directory ( myProject2 in your case)
  • The root project directory (under myProject )

Gradle looks for gradle.properties in all of these places, preferring property definitions based on the order above. For example, for a property defined in gradle in the user's home directory (# 1) and subproject (# 2), its value will be taken from gradle in the user's home directory (# 1).

More information on this can be found in the gradle documentation here .

+37
May 19 '15 at 19:52
source share



All Articles