Skip to content

Commit 7cdf121

Browse files
authored
Add autoconfigure modules for Spring Boot called sentry-spring-boot and sentry-spring-boot-jakarta (#2880)
* Move sentry-spring-boot-starter to sentry-spring-boot module and have sentry-spring-boot-starter bring spring-boot-starter * Changelog * Improve changelog
1 parent fb296f0 commit 7cdf121

File tree

54 files changed

+354
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+354
-196
lines changed

.craft.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ targets:
2323
maven:io.sentry:sentry:
2424
maven:io.sentry:sentry-spring:
2525
maven:io.sentry:sentry-spring-jakarta:
26+
#maven:io.sentry:sentry-spring-boot:
27+
#maven:io.sentry:sentry-spring-boot-jakarta:
2628
maven:io.sentry:sentry-spring-boot-starter:
2729
maven:io.sentry:sentry-spring-boot-starter-jakarta:
2830
maven:io.sentry:sentry-servlet:

.github/ISSUE_TEMPLATE/bug_report_java.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ body:
1818
- sentry-opentelemetry-core
1919
- sentry-servlet
2020
- sentry-servlet-jakarta
21+
- sentry-spring-boot
22+
- sentry-spring-boot-jakarta
2123
- sentry-spring-boot-starter
2224
- sentry-spring-boot-starter-jakarta
2325
- sentry-spring

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
- More details for Sentry events: query, variables and response (where possible)
1313
- Breadcrumbs for operation (query, mutation, subscription), data fetchers and data loaders (Spring only)
1414
- Better hub propagation by using `GraphQLContext`
15+
- Add autoconfigure modules for Spring Boot called `sentry-spring-boot` and `sentry-spring-boot-jakarta` ([#2880](https://github.com/getsentry/sentry-java/pull/2880))
16+
- The autoconfigure modules `sentry-spring-boot` and `sentry-spring-boot-jakarta` have a `compileOnly` dependency on `spring-boot-starter` which is needed for our auto installation in [sentry-android-gradle-plugin](https://github.com/getsentry/sentry-android-gradle-plugin)
17+
- The starter modules `sentry-spring-boot-starter` and `sentry-spring-boot-starter-jakarta` now bring `spring-boot-starter` as a dependency
1518

1619
### Fixes
1720

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Sentry SDK for Java and Android
3838
| sentry-kotlin-extensions | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions) | 14 |
3939
| sentry-servlet | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet) | |
4040
| sentry-servlet-jakarta | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet-jakarta/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet-jakarta) | |
41+
| sentry-spring-boot | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot) |
42+
| sentry-spring-boot-jakarta | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot-jakarta/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot-jakarta) |
4143
| sentry-spring-boot-starter | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot-starter/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot-starter) |
4244
| sentry-spring-boot-starter-jakarta | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot-starter-jakarta/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot-starter-jakarta) |
4345
| sentry-spring | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring) |

sentry-spring-boot-jakarta/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
public final class io/sentry/spring/boot/jakarta/BuildConfig {
2+
public static final field SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME Ljava/lang/String;
3+
public static final field VERSION_NAME Ljava/lang/String;
4+
}
5+
6+
public class io/sentry/spring/boot/jakarta/InAppIncludesResolver : org/springframework/context/ApplicationContextAware {
7+
public fun <init> ()V
8+
public fun resolveInAppIncludes ()Ljava/util/List;
9+
public fun setApplicationContext (Lorg/springframework/context/ApplicationContext;)V
10+
}
11+
12+
public class io/sentry/spring/boot/jakarta/SentryAutoConfiguration {
13+
public fun <init> ()V
14+
}
15+
16+
public class io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfiguration {
17+
public fun <init> ()V
18+
public fun sentryLogbackInitializer (Lio/sentry/spring/boot/jakarta/SentryProperties;)Lio/sentry/spring/boot/jakarta/SentryLogbackInitializer;
19+
}
20+
21+
public class io/sentry/spring/boot/jakarta/SentryProperties : io/sentry/SentryOptions {
22+
public fun <init> ()V
23+
public fun getExceptionResolverOrder ()I
24+
public fun getLogging ()Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;
25+
public fun getReactive ()Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;
26+
public fun getUserFilterOrder ()Ljava/lang/Integer;
27+
public fun isUseGitCommitIdAsRelease ()Z
28+
public fun setExceptionResolverOrder (I)V
29+
public fun setLogging (Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;)V
30+
public fun setReactive (Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;)V
31+
public fun setUseGitCommitIdAsRelease (Z)V
32+
public fun setUserFilterOrder (Ljava/lang/Integer;)V
33+
}
34+
35+
public class io/sentry/spring/boot/jakarta/SentryProperties$Logging {
36+
public fun <init> ()V
37+
public fun getLoggers ()Ljava/util/List;
38+
public fun getMinimumBreadcrumbLevel ()Lorg/slf4j/event/Level;
39+
public fun getMinimumEventLevel ()Lorg/slf4j/event/Level;
40+
public fun isEnabled ()Z
41+
public fun setEnabled (Z)V
42+
public fun setLoggers (Ljava/util/List;)V
43+
public fun setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V
44+
public fun setMinimumEventLevel (Lorg/slf4j/event/Level;)V
45+
}
46+
47+
public class io/sentry/spring/boot/jakarta/SentryProperties$Reactive {
48+
public fun <init> ()V
49+
public fun isThreadLocalAccessorEnabled ()Z
50+
public fun setThreadLocalAccessorEnabled (Z)V
51+
}
52+
53+
public class io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration {
54+
public fun <init> ()V
55+
public fun sentryWebExceptionHandler (Lio/sentry/IHub;)Lio/sentry/spring/jakarta/webflux/SentryWebExceptionHandler;
56+
}
57+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import net.ltgt.gradle.errorprone.errorprone
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
import org.springframework.boot.gradle.plugin.SpringBootPlugin
4+
5+
plugins {
6+
`java-library`
7+
kotlin("jvm")
8+
jacoco
9+
id(Config.QualityPlugins.errorProne)
10+
id(Config.QualityPlugins.gradleVersions)
11+
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion
12+
id(Config.BuildPlugins.springBoot) version Config.springBoot3Version apply false
13+
}
14+
15+
configure<JavaPluginExtension> {
16+
sourceCompatibility = JavaVersion.VERSION_17
17+
targetCompatibility = JavaVersion.VERSION_17
18+
}
19+
20+
tasks.withType<KotlinCompile>().configureEach {
21+
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
22+
kotlinOptions.languageVersion = Config.kotlinCompatibleLanguageVersion
23+
}
24+
25+
dependencies {
26+
api(projects.sentry)
27+
api(projects.sentrySpringJakarta)
28+
compileOnly(projects.sentryLogback)
29+
compileOnly(projects.sentryApacheHttpClient5)
30+
compileOnly(Config.Libs.springBoot3Starter)
31+
compileOnly(platform(SpringBootPlugin.BOM_COORDINATES))
32+
compileOnly(projects.sentryGraphql)
33+
compileOnly(Config.Libs.springWeb)
34+
compileOnly(Config.Libs.springWebflux)
35+
compileOnly(Config.Libs.servletApiJakarta)
36+
compileOnly(Config.Libs.springBoot3StarterAop)
37+
compileOnly(Config.Libs.springBoot3StarterSecurity)
38+
compileOnly(Config.Libs.springBoot3StarterGraphql)
39+
compileOnly(Config.Libs.reactorCore)
40+
compileOnly(Config.Libs.contextPropagation)
41+
compileOnly(projects.sentryOpentelemetry.sentryOpentelemetryCore)
42+
43+
annotationProcessor(platform(SpringBootPlugin.BOM_COORDINATES))
44+
annotationProcessor(Config.AnnotationProcessors.springBootAutoConfigure)
45+
annotationProcessor(Config.AnnotationProcessors.springBootConfiguration)
46+
47+
compileOnly(Config.CompileOnly.nopen)
48+
errorprone(Config.CompileOnly.nopenChecker)
49+
errorprone(Config.CompileOnly.errorprone)
50+
errorprone(Config.CompileOnly.errorProneNullAway)
51+
compileOnly(Config.CompileOnly.jetbrainsAnnotations)
52+
53+
// tests
54+
testImplementation(projects.sentryLogback)
55+
testImplementation(projects.sentryApacheHttpClient5)
56+
testImplementation(projects.sentryTestSupport)
57+
testImplementation(kotlin(Config.kotlinStdLib))
58+
testImplementation(Config.TestLibs.kotlinTestJunit)
59+
testImplementation(Config.TestLibs.mockitoKotlin)
60+
testImplementation(Config.TestLibs.mockWebserver)
61+
62+
testImplementation(Config.Libs.okhttp)
63+
testImplementation(Config.Libs.springBoot3Starter)
64+
testImplementation(platform(SpringBootPlugin.BOM_COORDINATES))
65+
testImplementation(Config.Libs.springBoot3StarterTest)
66+
testImplementation(Config.Libs.springBoot3StarterWeb)
67+
testImplementation(Config.Libs.springBoot3StarterWebflux)
68+
testImplementation(Config.Libs.springBoot3StarterSecurity)
69+
testImplementation(Config.Libs.springBoot3StarterAop)
70+
testImplementation(projects.sentryOpentelemetry.sentryOpentelemetryCore)
71+
testImplementation(Config.Libs.contextPropagation)
72+
}
73+
74+
configure<SourceSetContainer> {
75+
test {
76+
java.srcDir("src/test/java")
77+
}
78+
}
79+
80+
jacoco {
81+
toolVersion = Config.QualityPlugins.Jacoco.version
82+
}
83+
84+
tasks.jacocoTestReport {
85+
reports {
86+
xml.required.set(true)
87+
html.required.set(false)
88+
}
89+
}
90+
91+
tasks {
92+
jacocoTestCoverageVerification {
93+
violationRules {
94+
rule { limit { minimum = Config.QualityPlugins.Jacoco.minimumCoverage } }
95+
}
96+
}
97+
check {
98+
dependsOn(jacocoTestCoverageVerification)
99+
dependsOn(jacocoTestReport)
100+
}
101+
}
102+
103+
buildConfig {
104+
useJavaOutput()
105+
packageName("io.sentry.spring.boot.jakarta")
106+
buildConfigField("String", "SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME", "\"${Config.Sentry.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME}\"")
107+
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
108+
}
109+
110+
val generateBuildConfig by tasks
111+
tasks.withType<JavaCompile>().configureEach {
112+
dependsOn(generateBuildConfig)
113+
options.errorprone {
114+
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
115+
option("NullAway:AnnotatedPackages", "io.sentry")
116+
}
117+
}
Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +0,0 @@
1-
public final class io/sentry/spring/boot/jakarta/BuildConfig {
2-
public static final field SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME Ljava/lang/String;
3-
public static final field VERSION_NAME Ljava/lang/String;
4-
}
5-
6-
public class io/sentry/spring/boot/jakarta/InAppIncludesResolver : org/springframework/context/ApplicationContextAware {
7-
public fun <init> ()V
8-
public fun resolveInAppIncludes ()Ljava/util/List;
9-
public fun setApplicationContext (Lorg/springframework/context/ApplicationContext;)V
10-
}
11-
12-
public class io/sentry/spring/boot/jakarta/SentryAutoConfiguration {
13-
public fun <init> ()V
14-
}
15-
16-
public class io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfiguration {
17-
public fun <init> ()V
18-
public fun sentryLogbackInitializer (Lio/sentry/spring/boot/jakarta/SentryProperties;)Lio/sentry/spring/boot/jakarta/SentryLogbackInitializer;
19-
}
20-
21-
public class io/sentry/spring/boot/jakarta/SentryProperties : io/sentry/SentryOptions {
22-
public fun <init> ()V
23-
public fun getExceptionResolverOrder ()I
24-
public fun getLogging ()Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;
25-
public fun getReactive ()Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;
26-
public fun getUserFilterOrder ()Ljava/lang/Integer;
27-
public fun isUseGitCommitIdAsRelease ()Z
28-
public fun setExceptionResolverOrder (I)V
29-
public fun setLogging (Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;)V
30-
public fun setReactive (Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;)V
31-
public fun setUseGitCommitIdAsRelease (Z)V
32-
public fun setUserFilterOrder (Ljava/lang/Integer;)V
33-
}
34-
35-
public class io/sentry/spring/boot/jakarta/SentryProperties$Logging {
36-
public fun <init> ()V
37-
public fun getLoggers ()Ljava/util/List;
38-
public fun getMinimumBreadcrumbLevel ()Lorg/slf4j/event/Level;
39-
public fun getMinimumEventLevel ()Lorg/slf4j/event/Level;
40-
public fun isEnabled ()Z
41-
public fun setEnabled (Z)V
42-
public fun setLoggers (Ljava/util/List;)V
43-
public fun setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V
44-
public fun setMinimumEventLevel (Lorg/slf4j/event/Level;)V
45-
}
46-
47-
public class io/sentry/spring/boot/jakarta/SentryProperties$Reactive {
48-
public fun <init> ()V
49-
public fun isThreadLocalAccessorEnabled ()Z
50-
public fun setThreadLocalAccessorEnabled (Z)V
51-
}
52-
53-
public class io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration {
54-
public fun <init> ()V
55-
public fun sentryWebExceptionHandler (Lio/sentry/IHub;)Lio/sentry/spring/jakarta/webflux/SentryWebExceptionHandler;
56-
}
57-

sentry-spring-boot-starter-jakarta/build.gradle.kts

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ plugins {
88
jacoco
99
id(Config.QualityPlugins.errorProne)
1010
id(Config.QualityPlugins.gradleVersions)
11-
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion
1211
id(Config.BuildPlugins.springBoot) version Config.springBoot3Version apply false
1312
}
1413

@@ -23,22 +22,8 @@ tasks.withType<KotlinCompile>().configureEach {
2322
}
2423

2524
dependencies {
26-
api(projects.sentry)
27-
api(projects.sentrySpringJakarta)
28-
compileOnly(projects.sentryLogback)
29-
compileOnly(projects.sentryApacheHttpClient5)
30-
compileOnly(Config.Libs.springBoot3Starter)
31-
compileOnly(platform(SpringBootPlugin.BOM_COORDINATES))
32-
compileOnly(projects.sentryGraphql)
33-
compileOnly(Config.Libs.springWeb)
34-
compileOnly(Config.Libs.springWebflux)
35-
compileOnly(Config.Libs.servletApiJakarta)
36-
compileOnly(Config.Libs.springBoot3StarterAop)
37-
compileOnly(Config.Libs.springBoot3StarterSecurity)
38-
compileOnly(Config.Libs.springBoot3StarterGraphql)
39-
compileOnly(Config.Libs.reactorCore)
40-
compileOnly(Config.Libs.contextPropagation)
41-
compileOnly(projects.sentryOpentelemetry.sentryOpentelemetryCore)
25+
api(projects.sentrySpringBootJakarta)
26+
api(Config.Libs.springBoot3Starter)
4227

4328
annotationProcessor(platform(SpringBootPlugin.BOM_COORDINATES))
4429
annotationProcessor(Config.AnnotationProcessors.springBootAutoConfigure)
@@ -49,26 +34,6 @@ dependencies {
4934
errorprone(Config.CompileOnly.errorprone)
5035
errorprone(Config.CompileOnly.errorProneNullAway)
5136
compileOnly(Config.CompileOnly.jetbrainsAnnotations)
52-
53-
// tests
54-
testImplementation(projects.sentryLogback)
55-
testImplementation(projects.sentryApacheHttpClient5)
56-
testImplementation(projects.sentryTestSupport)
57-
testImplementation(kotlin(Config.kotlinStdLib))
58-
testImplementation(Config.TestLibs.kotlinTestJunit)
59-
testImplementation(Config.TestLibs.mockitoKotlin)
60-
testImplementation(Config.TestLibs.mockWebserver)
61-
62-
testImplementation(Config.Libs.okhttp)
63-
testImplementation(Config.Libs.springBoot3Starter)
64-
testImplementation(platform(SpringBootPlugin.BOM_COORDINATES))
65-
testImplementation(Config.Libs.springBoot3StarterTest)
66-
testImplementation(Config.Libs.springBoot3StarterWeb)
67-
testImplementation(Config.Libs.springBoot3StarterWebflux)
68-
testImplementation(Config.Libs.springBoot3StarterSecurity)
69-
testImplementation(Config.Libs.springBoot3StarterAop)
70-
testImplementation(projects.sentryOpentelemetry.sentryOpentelemetryCore)
71-
testImplementation(Config.Libs.contextPropagation)
7237
}
7338

7439
configure<SourceSetContainer> {
@@ -100,16 +65,7 @@ tasks {
10065
}
10166
}
10267

103-
buildConfig {
104-
useJavaOutput()
105-
packageName("io.sentry.spring.boot.jakarta")
106-
buildConfigField("String", "SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME", "\"${Config.Sentry.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME}\"")
107-
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
108-
}
109-
110-
val generateBuildConfig by tasks
11168
tasks.withType<JavaCompile>().configureEach {
112-
dependsOn(generateBuildConfig)
11369
options.errorprone {
11470
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
11571
option("NullAway:AnnotatedPackages", "io.sentry")

0 commit comments

Comments
 (0)