Skip to content

/flags/gradle/gradle-stacktrace

gradle --stacktrace, --info, --debug, --scan: get more detail on a failed build

The commands on this page have not been executed by our verification runner yet.updated
tool
Gradle
command
gradle, ./gradlew
flag
-s, --stacktrace; -S, --full-stacktrace; -i, --info; -d, --debug; --scan
default
no stack trace; log level lifecycle

When a Gradle build fails, the console shows only the error message and a "Try:" block that suggests --stacktrace, --info or --debug and --scan. ./gradlew build --stacktrace (short -s) reruns the build and prints the Java stack trace of the failure, which shows which plugin, task or script line threw it. --info (-i) and --debug (-d) raise the log level instead, and --scan uploads a browsable report. Each answers a different question, so pick the lightest one that does.

The suggestion block

A failing build ends like this:

text
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
bash
./gradlew build --stacktrace          # where did the exception come from?
./gradlew build --info                # what did Gradle do (dependency resolution, task inputs)?
./gradlew build --info --stacktrace   # both
./gradlew build --scan                # shareable report with timeline and dependencies

Which option for which question

OptionShowsUse when
-s, --stacktraceStack trace of the failure (filtered)An exception without an obvious cause
-S, --full-stacktraceEvery frame, including Gradle internalsReporting a Gradle or plugin bug
-i, --infoInfo-level log: resolution, task actions, up-to-date reasonsDependency or caching questions
-d, --debugEverything, very verboseLast resort; may contain credentials
-w, --warn / -q, --quietFewer messagesCleaner CI logs
--scanOnline report (build scan)Sharing a failure with a team or plugin author
--warning-mode allEvery deprecation warning with its locationPreparing a Gradle upgrade

Permanent settings

properties
# gradle.properties
org.gradle.logging.level=info         # quiet, warn, lifecycle, info, debug
org.gradle.warning.mode=all

On CI, add --stacktrace to the build command permanently: rerunning a failed build only to see the trace wastes time, and the trace costs nothing when the build passes.

Reading a stack trace

Look for the first Caused by: lines: the top of the trace is usually Gradle's own wrapping exception, while the cause names the real problem, for example a missing plugin repository (Plugin was not found) or a DSL mistake (Could not find method implementation()). Lines with build.gradle or build.gradle.kts and a line number point at your script.

Pitfalls

  • --debug output is huge and can include secrets from environment variables and repository credentials; never paste it unreviewed.
  • The options must reach the build: with a wrapper script call ./gradlew --stacktrace build; in IDEs, add them to the run configuration's arguments.
  • For dependency version questions, the dependencies report is clearer than --info output.

FAQ

What is the difference between --stacktrace and --full-stacktrace?

--stacktrace (-s) prints the stack trace of the exception with internal Gradle frames filtered out. --full-stacktrace (-S) prints every frame, which is mainly useful when reporting a bug in Gradle or a plugin.

Is it safe to share --debug output?

Be careful. Debug logs can contain credentials, tokens and environment details. Use --info or --stacktrace for issue reports, and review any debug log before posting it.

Does --scan upload my build data?

Yes. --scan publishes a build scan to scans.gradle.com (or your Develocity server) after you accept the terms of service. Do not use it for confidential projects unless you run your own server.

Sources