推荐的方法来停止Gradle构建 [英] Recommended way to stop a Gradle build

查看:161
本文介绍了推荐的方法来停止Gradle构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在检测到问题后停止Gradle构建?我可以使用一个断言,抛出一个异常,做一个System.exit(坏主意),或者在Gradle中使用一个专用函数(但是我找不到一个)。什么是Gradle的最佳方式(以及为什么?)。

How can I stop a Gradle build after detecting a problem? I can use an assert, throw an exception, do a System.exit (bad idea), or use a dedicated function in Gradle (but I could not find one). What is the best way for Gradle (and why?).

推荐答案

我通常从 org.gradle.api package ,例如 InvalidUserDataException 表示某人输入了无效的内容,或 GradleScriptException 以获取更多一般性错误。

I usually throw the relevant exception from the org.gradle.api package, for example InvalidUserDataException for when someone has entered something invalid, or GradleScriptException for more general errors.

如果您想停止当前的任务或动作,并转到下一个动作,则还可以通过 StopActionException

If you want to stop the current task or action, and move on to the next, you can also throw a StopActionException

这篇关于推荐的方法来停止Gradle构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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