Custom task: check --stacktrace option

I am writing a custom plugin and I need to output exceptions to the log only when the --stacktrace option is specified. How can I check this?

You can find that information through the property project.gradle.startParameter.showStacktrace. It’s an enum of either INTERNAL_EXCEPTIONS, ALWAYS or ALWAYS_FULL.

Hope this helps, even though our community is apparently giving you the worst support you’ve ever seen :slight_smile:

1 Like

How exactly i can check this? I trid getProject().hasProperty("showStacktrace") and getProject().hasProperty("project.gradle.startParameter.showStacktrace") but it not work

Hi,
if you are in your plugin or task you can try:
getProject().getGradle().getStartParameter().getShowStacktrace().equals(ShowStacktrace.ALWAYS)

Cheers
Markus

Thx mate. Bit this is enum so we can use ==. I think this more convinient.

Yes, should work, too :wink: