When compiling a groovy project, gradle creates files in $projectRoot/build/
. Is there a way to configure this to e.g. an absolute path?
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
-
Windows absolute path like
buildDir = 'R:\\buildMaria'
worked inbuild.gradle
but failed ingradle.properties
See also stackoverflow.com/questions/29116000/gradle-make-use-of-ramdisk – Paul Verest Mar 18 '15 at 7:42 -
3can it be done with some env variable? i need it to configure CI for the project – 4ntoine Dec 21 '17 at 12:16
-
So,t he key for
gradle.properties
isproject.buildDir=new/directory/location
? – FilBot3 Jan 15 '20 at 21:03
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)
-
2
You can add project.buildDir = 'your/directory' to the file build.gradle you can place it anywhere in separate line