# Gradle | Sentry for Java

The [Sentry Gradle Plugin](https://github.com/getsentry/sentry-android-gradle-plugin.md) 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

## [Setup](https://docs.sentry.io/.md#setup)

### [Install](https://docs.sentry.io/.md#install)

Using Gradle in your application module's `build.gradle` add:

```groovy
plugins {
    id "io.sentry.jvm.gradle" version "5.8.0"
}
```

For non-Android projects, the plugin only collects external dependencies and uploads [Source Context](https://docs.sentry.io/platforms/java/source-context.md).

### [Configure](https://docs.sentry.io/.md#configure)

We expose the following configuration values directly in `build.gradle`:

```groovy
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
    }
}
```

## [Auto Installation](https://docs.sentry.io/.md#auto-installation)

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.

## [Source Context](https://docs.sentry.io/.md#source-context)

See our documentation on [Source Context](https://docs.sentry.io/platforms/java/source-context.md).

## [Dependencies Report](https://docs.sentry.io/.md#dependencies-report)

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:

[![Java dependencies report](https://docs.sentry.io/_next/image/?url=%2Fmdx-images%2Fdependencies-report-66GJ4D2Z.png%231355x653\&w=3840\&q=75)](https://docs.sentry.io/mdx-images/dependencies-report-66GJ4D2Z.png)
