Is there a way I can set --info
or --stacktrace
via gradle.properties
?
I currently have a gazillion build scripts that end up invoking gradle at some point, and I would like to standardize the error handling behavior across the board.
Gradle allows you to define one or more default tasks that are executed if no other tasks are specified. defaultTasks 'clean', 'run' tasks. register('clean') { doLast { println 'Default Cleaning! ' } } tasks.
After generating the Eclipse project files, you can import the project into a Eclipse workspace. It is important to add the GRADLE_USER_HOME variable in Eclipse: Window->Preferences->Java->Build Path->Classpath Variable. Set it to the path of the ~/. gradle folder in your home directory (e.g. /home/<user_name>/.
View -> Tool Windows -> Build. There is small "ab" button on the left panel. All gradle logs for current build are there.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With