Change Gradle's working directory when compiling a Groovy project

后端 未结 3 1465
迷失自我
迷失自我 2021-01-01 16:48

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

相关标签:
3条回答
  • 2021-01-01 17:33

    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
    
    0 讨论(0)
  • 2021-01-01 17:39

    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)

    0 讨论(0)
  • 2021-01-01 17:47

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

    0 讨论(0)
提交回复
热议问题