推荐的方式来停止摇篮构建 [英] Recommended way to stop a build with Gradle
问题描述
如何才能停止在与我建立摇篮问题构建?我可以使用一个断言,抛出一个异常,做一个System.exit(坏主意),或在摇篮使用专用功能(但我无法找到一个)。什么是摇篮(为什么?)的最佳方式。
How can I stop a build following a problem with my build in Gradle? 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
包装相关的异常,例如<一个href=\"http://gradle.org/docs/current/javadoc/org/gradle/api/InvalidUserDataException.html\"><$c$c>InvalidUserDataException$c$c>当有人进入一些无效,或<一个href=\"http://gradle.org/docs/current/javadoc/org/gradle/api/GradleScriptException.html\"><$c$c>GradleScriptException$c$c>更普遍的错误。
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.
如果要停止当前任务或行动,并移动到下一个,你也可以抛出一个<一个href=\"http://gradle.org/docs/current/javadoc/org/gradle/api/tasks/StopActionException.html\"><$c$c>StopActionException$c$c>
If you want to stop the current task or action, and move on to the next, you can also throw a StopActionException
这篇关于推荐的方式来停止摇篮构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!