gradle-自定义build.gradle和settings.gradle [英] gradle - custom build.gradle AND settings.gradle

查看:453
本文介绍了gradle-自定义build.gradle和settings.gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人,

有人知道如何使用gradle与自定义build.gradlesettings.gradle一起运行吗?

is anyone aware how to use gradle to run with a custom build.gradle AND settings.gradle - i.e both together?

我认为我可以有一个自定义的build.gradle文件(-b标志)-但这会忽略自定义设置标志-c标志.

I think that I can have a custom build.gradle file (-b flag) - but then this ignores the custom settings flag -c flag.

我认为(尽管我不能立即指向文档中的那一部分),如果您专门指定了一个自定义的build.gradle,那么它将忽略您的settings.gradle覆盖-c选项.

I think (although I can't immediatley point to thepart in the documentation) that if you specificy a custom build.gradle, then it ignores your settings.gradle override -c option.

如果这不可能-是否可以仅使用build.gradle文件并忽略任何settings.gradle

If this isn't possible - is it possible to inform gradle of a multiproject build using only a build.gradle file and ignoring any settings.gradle

动机是创建一个仅运行某些元素的相当大且复杂的构建的精简版".

motivation is to create a 'lite' version of a fairly large and complex build that only runs certain elements.

推荐答案

Gradle的一般原理是在一个构建模型中表达所有不同的用法.也就是说,这里有一些想法:

The general philosophy of Gradle is to express all different usages in a single build model. That said, here are a few thoughts:

-b使用给定的构建脚本强制进行单项目构建.我会说此功能主要用于演示目的,而我还没有将其用于生产版本.

-b forces a single-project build using the given build script. I'd say that this feature is mainly intended for demonstration purposes, and I haven't used it for production builds.

在多项目构建中,构建脚本的位置仅由设置脚本确定.默认情况下,Gradle将查找名为settings.gradle的设置脚本.但是,您可以具有多个设置脚本,并使用-c选项在其中选择,或者在不同目录中具有多个settings.gradle,然后通过从适当的目录开始构建来在它们之间进行选择.作为最后的选择,您可以编写一个设置脚本,该脚本根据某些条件有条件地包括不同的项目,或指向不同的构建脚本.请注意,即使是单项目构建,也可以具有设置脚本.

In a multi-project build, the location of build scripts is solely determined by the settings script. By default, Gradle will look for a settings script named settings.gradle. However, you could have multiple settings scripts and choose among them with the -c option, or have multiple settings.gradle in different directories and choose among them by starting the build from the appropriate directory. As a last resort, you could write a settings script that conditionally includes different projects, or points to different build scripts, depending on some condition. Note that even single-project builds can have a settings script.

要探索可用于设置脚本的API,请在中查找Settings类型. Gradle构建语言参考.

To explore the API available to settings scripts, look up the Settings type in the Gradle Build Language Reference.

这篇关于gradle-自定义build.gradle和settings.gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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