停止 Gradle 构建的推荐方法 [英] Recommended way to stop a Gradle build
问题描述
如何在检测到问题后停止 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
包,例如 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屋!