Android Studio-全局设置构建目录(每台机器) [英] Android Studio - set build directory globally (per machine)

查看:236
本文介绍了Android Studio-全局设置构建目录(每台机器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以手动设置构建目录,例如如下所示:

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

这可以在我项目的build.gradle中完成.我只想在一台计算机上更改此目录,所以我想以某种方式全局定义此目录,例如在全局属性gradle.properties"文件中定义凭据.

我可以以某种方式在一台计算机上全局定义buildDir吗?我想在多台计算机上使用同一项目,而又不总是更改build.gradle文件,而是希望每台计算机上都有单独的构建目录...

解决方案

创建一个文件camel"gradle.properties",在其中设置所需的属性,然后将其放入".gradle"文件夹(安装了gradle的文件夹)

在Linux中,.gradle"通常位于"/home/[]您的用户名]/.gradle"中

然后在所有项目的项目结构的android视图中,该文件将显示为名称"gradle.properties(全局属性)"

更新:

如果要使用全局脚本文件而不是属性文件,则可以使用初始化脚本.创建一个名为"init.gradle"的文件,并将其放在同一目录中.

您的init.gradle内容如下:

allprojects {
buildDir = "whatever directory you want"
}

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...

解决方案

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"
}

这篇关于Android Studio-全局设置构建目录(每台机器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆