user3601487
user3601487

Reputation: 1107

What is Gradle's $rootDir/gradle directory for?

What is $rootDir/gradle directory for (not .gradle)? Is anything from this directory read by default during a build? Is there a convention regarding what should be put in this directory?

Upvotes: 2

Views: 17638

Answers (2)

LazerBanana
LazerBanana

Reputation: 7211

Well, gradle directory is used to store a distributed version of a Gradle wrapper also it has become some sort of convention to put most of the common scripts that are used in sub projects, which then can be extended, in an example:

repositories.gradle

repositories {
    mavenLocal()
    maven {
        url "http://nexus"
    }
}

therefore each sub project doesn't need to have this in its script and you can just

apply from: "$rootDir/gradle/repositories.gradle"

or let's say you have some java specific things you don't want to flood your main scripts with etc.

It keeps things clean and more readable, rather than having everything in 1 script and scroll through it forever.

it can also hold configuration properties, JUnit config, log4j config, and so on, basically everything you want, in an example:

environment.groovy

oracle {
  home = "C:/"   
  tablespace = "TABLE"
  dbaUser = "user"
  dbaPassword = "psswrd"
}

The folder itself is not 'special' the special folder is buildSrc which Gradle reads before it even starts evaluating your scripts, this is the place to create some custom tasks, plugins etc.

Upvotes: 4

user3601487
user3601487

Reputation: 1107

So far I've seen only two uses of this directory:

1) Gradle wrapper uses it to store wrapper JAR file along with some properties.

2) In "Gradle In Action" the author uses this directory to store properties in versioning.gradle for hand-written versioning plugin and then uses it like this:

allprojects {
...
apply from: "$rootDir/gradle/versioning.gradle"
}

It seems it's a good place to keep build plugins' properties that are not strictly related to a particular project and which should be checked in to the repository.

Upvotes: 0

Related Questions