Maven

The 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

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

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

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

Copied
<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>io.sentry</groupId>
        <artifactId>sentry-maven-plugin</artifactId>
        <version>0.0.7</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>
        </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>
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

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.

Help improve this content
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").