Gradle console output cleared after error
已回答
I think it's a known issue that System.out doesn't display in the console window for gradle projects, in some cases. A particularly bad case is when an error occurs. IDEA clears the console after the error, so you can't see what the error was.
Is there a solution to this?
请先登录再写评论。
Hi, please provide more details about the problem. Is it specific to a single project?
What kind of project is it? Can you share it so that I can try reproducing the issue?
Are you aware of any particular issues on YouTrack opened with regards to this problem?
It is a gradle project. Whenever, I run a main java class and it results in an exception, the console window is then cleared, so you can't see what the exception was.
If I debug the program and use printStackTrace, and step over it, it does print in the console window. So, with effort that is a way to see what the problem was. But, it would be much more useful if the console output was preserved.
If I the step over a throw statement, there is an entry that just displays just the message of the top-level exception. Below that is the exit result, with the console window only containing the ending lines that gradle prints. Much less useful that console output.
Please provide a self-sustained code sample, the entire output of the console window after you run it, and a screenshot of the corresponding Run/Debug Configuration (Run | Edit Configurations).
I hope this is what you are asking for. This is the code:
This is build.gradle (it's gradle 7.5):
plugins {
id 'java-library'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8);
}
}
repositories {
mavenCentral()
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:31.0.1-jre'
}
testing {
suites {
test {
// Use JUnit Jupiter test framework
useJUnitJupiter('5.8.2')
}
}
}
This is the entire console tab contents, after running the program:
Thanks, I'll try to reproduce this and get back to you.
Try checking the output up one level:
Ah. I didn't think to look there. Ok. That works.