我尝试在我的 CentOS 机器上运行 gradle,但它不打印任何输出。只有像 gradle -v 或 gradle -qtasks 这样的东西才会带来一些非常基本的信息。主要问题是,我收到编译错误,但它没有告诉我它在哪里。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
Cause: Compile failed; see the compiler error output for details.
JAVA_HOME 和 GRADLE_HOME 已设置。类路径为空。有什么想法吗?
gradle -v
Gradle 1.0-milestone-7
Gradle build time: Thursday, January 5, 2012 10:24:43 AM UTC
Groovy: 1.8.4
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_24 (Sun Microsystems Inc. 19.1-b02)
OS: Linux 2.6.18-274.17.1.el5 amd64
编译器错误输出应显示在FAILURE: Build failed with an exception
消息上方
。
-q
提供的输出比正常情况下少,但您可以尝试
-i
。您还可以使用
-S
查看堆栈跟踪。最后但并非最不重要的一点是,我建议尝试更新的 Gradle 版本(例如 1.0-rc-3)。
gradle wrapper --gradle-version 2.13
只需使用您的 gradle 版本或简单地:
gradle wrapper
它将自动执行此操作。
$ ./gradlew clean build
> Task :integrationTest
SystemTest > MyApp system test FAILED
org.opentest4j.AssertionFailedError at SystemTest.java:40
1 test completed, 1 failed
> Task :integrationTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':integrationTest'.
> There were failing tests. See the report at: file:///Users/me/repos/myFolder/my-app/build/reports/tests/integrationTest/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1/userguide/command_line_interface.html#sec:command_line_warnings
我发现调试语句实际上被正确记录了。我只需要转到引用的测试输出 HTML 文件并单击“标准输出”按钮。一旦到达那里,我记录的所有调试语句都会出现。
tasks.withType(Test) {
testLogging.showStandardStreams = true
}
以上影响所有测试任务,如integrationTest
。如果您只需要执行一项任务,例如
test
,
test {
testLogging.showStandardStreams = true
}
另一个方法是从 IntelliJ Idea 而不是命令行运行测试:在这种情况下,您将看到测试的输出。
.bashrc
(或您选择的任何 shell)中。
export $CLASSPATH=/path/to/java/