Armand
Armand

Reputation: 24393

Change Gradle's working directory when compiling a Groovy project

When compiling a groovy project, gradle creates files in $projectRoot/build/. Is there a way to configure this to e.g. an absolute path?

Upvotes: 19

Views: 58118

Answers (3)

Dalibor Filus
Dalibor Filus

Reputation: 1254

You can set project.buildDir in your build.gradle, or buildDir = PATH in gradle.properties.

And from environment variable like this:

export GRADLE_OPTS=-Dorg.gradle.project.buildDir=/tmp/gradle-build

See Build Environment section of the documentation here: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_environment_variables

And Writing Build Scripts here (for buildDir property): https://docs.gradle.org/current/userguide/writing_build_scripts.html

(Current version of gradle when writing this: 4.5)

Upvotes: 8

tarn
tarn

Reputation: 556

You can add project.buildDir = 'your/directory' to the file build.gradle you can place it anywhere in separate line

Upvotes: 3

Sergey Weiss
Sergey Weiss

Reputation: 5974

Yes, there is. You can put the following line in your build script:

buildDir = 'your_directory'

Or in gradle.properties file (no quotes around your_directory in that case).


Build directory is a project property. You can view all project properties available to you by typing:

gradle properties

Upvotes: 38

Related Questions