简体   繁体   中英

setup global gradle build dir relative path

I would like to setup a global gradle build dir that points to a ramdisk. I've tried numerous ways of setting up the build dir in my global gradle.properties file located at ~/.gradle/gradle.properties .

The issue I'm facing is that gradle does not evaluate the variables/relative-expressions that are included in the buildDir config. How do I setup a global build dir that takes care of project specific subfolders?

gradle.projectsLoaded {
    rootProject.allprojects {
        buildDir=~/.gradle/build/${rootProject.name}/${project.name}
    }
}

OK, I've figured it out. The main reason for my issues where that I've assumed that the gradle.properties files also executes included scripting expressions (ie, the included variables and string formatting).

This is not the case!

So, to solve this issue I came up with the following init.gradle file ( ~/.gradle/init.gradle ):

allprojects {
        buildDir="$System.env.HOME/.gradle/build/${it.name}/"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM