gradle - custom build.gradle AND settings.gradle

℡╲_俬逩灬. 提交于 2019-12-13 06:27:28

问题


folks,

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

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

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.

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.


回答1:


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

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

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.

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



来源:https://stackoverflow.com/questions/19915810/gradle-custom-build-gradle-and-settings-gradle

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