Android Studio - set build directory globally (per machine)

孤人 提交于 2019-12-11 08:43:10

问题


I can set the build directory manually like following for example:

allprojects {
    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
}

This can be done in my project's build.gradle. I want to change this directory on one computer only, so I want to somehow define this globally like I for example define credentials in the Global Properties gradle.properties file.

Can I somehow define the buildDir globally on one machine? I want to use the same project on multiple machines and without always changing the build.gradle file, I want to have individual build directories on each machine...


回答1:


create a file camed "gradle.properties" set your desired properties in it and put it in ".gradle" folder (where your gradle is installed)

in linux ".gradle" is normally in "/home/[]your_user_name]/.gradle"

then in android view of project structure of all your project this file will appear with the name "gradle.properties (Global Properties)"

UPADATE:

if you want a global script file rather than properties file you can use init script. create a file named "init.gradle" and put it in the same directory.

your init.gradle content would be like:

allprojects {
buildDir = "whatever directory you want"
}


来源:https://stackoverflow.com/questions/39868040/android-studio-set-build-directory-globally-per-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!