Gradle
Learn about using the Sentry Gradle Plugin.
The Sentry Gradle Plugin is an addition to the main Java SDK and offers seamless integration with the Gradle build system. It supports the following features:
- Auto-installation of Sentry Java SDK and relevant integrations
- External dependencies report
- Uploading Source Context
Using Gradle in your application module's build.gradle
add:
plugins {
id "io.sentry.jvm.gradle" version "4.7.1"
}
For non-Android projects, the plugin only collects external dependencies and uploads Source Context.
We expose the following configuration values directly in build.gradle
:
sentry {
// Enables more detailed log output, e.g. for sentry-cli.
//
// Default is false.
debug = true
// Generates a source bundle and uploads it to Sentry.
// This enables source context, allowing you to see your source
// code as part of your stack traces in Sentry.
//
// Default is disabled. To enable, see the source context guide.
includeSourceContext = true
// Includes additional source directories into the source bundle.
// These directories are resolved relative to the project directory.
additionalSourceDirsForSourceContext = ["mysrc/java", "other-source-dir/main/kotlin"]
// Disables or enables dependencies metadata reporting for Sentry.
// If enabled, the plugin will collect external dependencies and
// upload them to Sentry as part of events. If disabled, all the logic
// related to the dependencies metadata report will be excluded.
//
// Default is enabled.
includeDependenciesReport = true
// Automatically adds Sentry dependencies to your project.
autoInstallation {
enabled = true
}
}
The plugin automatically adds the Sentry Java SDK as well as available Sentry integrations as dependencies if it detects a library dependency we support. For example, if your project has a dependency on graphql-java
the plugin will automatically add sentry-graphql
as an additional dependency.
See our documentation on Source Context.
The plugin automatically collects an application's external dependencies (including transitive ones), and generates a compile-time report. The Sentry Java SDK picks up the report at runtime and sends it along with every Sentry event. The event dependencies metadata will look something like this:
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").