Maven
Learn about using the Sentry Maven Plugin.
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:
<project>
...
<build>
<plugins>
<plugin>
<groupId>io.sentry</groupId>
<artifactId>sentry-maven-plugin</artifactId>
<version>0.4.0</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
:
<project>
...
<build>
<plugins>
<plugin>
<groupId>io.sentry</groupId>
<artifactId>sentry-maven-plugin</artifactId>
<version>0.4.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>
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.
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
:
<additionalSourceDirsForSourceContext>
<value>src/main/someDirectory</value>
<value>src/main/someOtherDirectory</value>
</additionalSourceDirsForSourceContext>
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").