在STS Gradle中禁用stracktrace / BuildException输出的打印

时间:2016-08-24 06:53:06

标签: java eclipse spring gradle

目前我正在通过Eclipse Neo和STS Gradle Plugin运行Gradle 2.x / 3.x版本。如果在构建时出现问题,例如在compileJava任务中,我得到了一个错误的详细信息(imo在eclipse的控制台选项卡中打印到stderr,然后是一种用于构建异常的堆栈跟踪(imo打印到控制台选项卡中的stdout)。

以下是输出示例:

[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks: 
[sts]      compileJava
[sts] -----------------------------------------------------
[...]
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or  --debug option to get more log output.
[sts] Build failed
org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.14-bin.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:57)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at org.[...]

stacktrace伴随着 [sts] 所以我认为它不是直接来自Gradle。有没有办法抑制堆栈跟踪的打印?

1 个答案:

答案 0 :(得分:1)

gradle STS构建插件不提供禁用此堆栈跟踪打印的方法 这可以通过查看how this stack trace printing is implemented in the plugin source来验证 所有输出都发送到同一个打印流,没有记录框架或配置选项,可以精确控制打印的内容。
值得注意的是,此插件已被弃用(并且维护得很少),支持buildship plugin。 buildship插件没有表现出相同的堆栈跟踪打印行为。