Search code examples
kotlingradleintellij-ideagradle-kotlin-dsl

How to make IntelliJ show Kotlin exception messages when using Gradle?


I have a kotlin App that throws an IllegalArgumentException at some point, and I'd like to see that exception in the console (I'm using IntelliJ). However, the IntelliJ terminal just prints the following Gradle output:

Execution failed for task ':app:run'.
> Process 'command '/Users/tom/.gradle/jdks/eclipse_adoptium-21-aarch64-os_x.2/jdk-21.0.5+11/Contents/Home/bin/java'' finished with non-zero exit value 1

It also suggested to run it with the stack trace or debugging level, but it just shows the stack trace for the Gradle-internal stuff, not why the process finished with exit code 1. How can I make Gradle display that?


Solution

  • I think all that is happening here is the IntelliJ terminal is not showing the full output and you need to select one of the other output display options.

    To be precise, when I run a Gradle run command using IntelliJ, I get the below display in the left-hand pane, here using an example project.

    When the bottom option ("Process 'command '....") is highlighted (as in the image), a shortened version of the output is shown which does not include the program stack trace. However, when either of the other two options (in mine, ":subProject:run" or "sandboxsubProject [run]...") is selected, the whole output from the execution of the program is shown (and in the latter case, also shown is some Gradle output from the build process).

    So clicking on either of the two other output options should show the stack trace you want.

    IntelliJ run window left-hand pane screenshot