How can I make "gradle --stacktrace" the default?

There is another approach where you do not have to edit the build.gradle file because you may not want it so verbose when you run your CI. In addition, you now have to remember to turn it off in CI. So, instead, you can limit to the IDE. If you are using eclipse, you can follow these steps to apply it only to gradle runs within your IDE.

Run -> "Run Configurations" -> Select "Gradle Project" -> Click "Project Settings" tab -> Click "Configure project settings..." link -> Select "Override workspace settings" -> paste "--stacktrace" in "Program Arguments" text field.

The above worked with Spring Tool Suite 4.2.1 which is based on Eclipse 4.11.0.x


Not in gradle.properties but in build.gradle itself. Add the following piece of code at the very beginning of the build script:

import org.gradle.logging.ShowStacktrace
gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS
throw new RuntimeException('lol')

Or in Android Studio:

import org.gradle.api.logging.configuration.ShowStacktrace
gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS

It also might be put in init script.

As pointed out in the comments, from gradle v. 2.14 it will be:

gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.ALWAYS

Tags:

Gradle