---
title: "Maven"
description: "Learn about using the Sentry Maven Plugin."
url: https://docs.sentry.io/platforms/java/guides/logback/maven/
---

# Maven | Sentry for Logback

The [Sentry Maven Plugin](https://github.com/getsentry/sentry-maven-plugin) is an addition to the main Java SDK and offers seamless integration with the Maven build system. It supports the following features:

* Auto-installation of Sentry Java SDK and relevant integrations
* Uploading Source Context

## [Setup](https://docs.sentry.io/platforms/java/guides/logback/maven.md#setup)

### [Install](https://docs.sentry.io/platforms/java/guides/logback/maven.md#install)

Using Maven in your application module's `pom.xml` add:

```xml
<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>io.sentry</groupId>
        <artifactId>sentry-maven-plugin</artifactId>
        <version>0.11.0</version>
        <!-- Required to allow auto-install of Sentry SDK and Integrations -->
        <extensions>true</extensions>
      </plugin>
      ...
    </plugins>
    ...
  </build>
...
</project>
```

### [Configure](https://docs.sentry.io/platforms/java/guides/logback/maven.md#configure)

We expose the following configuration values, by adding a `<configuration>` section to the plugin in `pom.xml`:

```xml
<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>io.sentry</groupId>
        <artifactId>sentry-maven-plugin</artifactId>
        <version>0.11.0</version>
        <!-- Required to allow auto-install of Sentry SDK and Integrations -->
        <extensions>true</extensions>
        <configuration>
          <!-- for showing output of sentry-cli -->
          <debugSentryCli>true</debugSentryCli>

          <!--  Disable the plugin -->
          <skip>false</skip>

          <!--  Disable source-context -->
          <skipSourceBundle>false</skipSourceBundle>

          <!--  Disable auto-install of SDK and Integrations -->
          <skipAutoInstall>false</skipAutoInstall>

          <!--  Disable validating consistency of SDK dependency versions -->
          <skipValidateSdkDependencyVersions>false</skipValidateSdkDependencyVersions>
        </configuration>
        <executions>
          <execution>
            <goals>
              <!--  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. -->
              <goal>uploadSourceBundle</goal>

              <!--  Validates Sentry SDK dependency versions. -->
              <!--  Mixing SDK dependency versions can result in build or run time errors. -->
              <!--  If mixed versions are detected, the build will fail. -->
              <goal>validateSdkDependencyVersions</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>
```

## [Auto Installation](https://docs.sentry.io/platforms/java/guides/logback/maven.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/platforms/java/guides/logback/maven.md#source-context)

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

By default, all of the source roots that are included as part of your build are sent to Sentry for source context.

To manually specify additional directories that shall be included in the source bundle, use the following configuration within your `plugin` tag for `io.sentry:sentry-maven-plugin`:

```xml
<additionalSourceDirsForSourceContext>
  <value>src/main/someDirectory</value>
  <value>src/main/someOtherDirectory</value>
</additionalSourceDirsForSourceContext>
```
