Skip to content

Commit

Permalink
Add autoconfigure modules for Spring Boot called sentry-spring-boot
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
adinauer authored Aug 4, 2023
1 parent fb296f0 commit 7cdf121
Show file tree
Hide file tree
Showing 54 changed files with 354 additions and 196 deletions.
2 changes: 2 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ targets:
maven:io.sentry:sentry:
maven:io.sentry:sentry-spring:
maven:io.sentry:sentry-spring-jakarta:
#maven:io.sentry:sentry-spring-boot:
#maven:io.sentry:sentry-spring-boot-jakarta:
maven:io.sentry:sentry-spring-boot-starter:
maven:io.sentry:sentry-spring-boot-starter-jakarta:
maven:io.sentry:sentry-servlet:
Expand Down
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ body:
- sentry-opentelemetry-core
- sentry-servlet
- sentry-servlet-jakarta
- sentry-spring-boot
- sentry-spring-boot-jakarta
- sentry-spring-boot-starter
- sentry-spring-boot-starter-jakarta
- sentry-spring
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
- More details for Sentry events: query, variables and response (where possible)
- Breadcrumbs for operation (query, mutation, subscription), data fetchers and data loaders (Spring only)
- Better hub propagation by using `GraphQLContext`
- Add autoconfigure modules for Spring Boot called `sentry-spring-boot` and `sentry-spring-boot-jakarta` ([#2880](https://github.com/getsentry/sentry-java/pull/2880))
- 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)
- The starter modules `sentry-spring-boot-starter` and `sentry-spring-boot-starter-jakarta` now bring `spring-boot-starter` as a dependency

### Fixes

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Sentry SDK for Java and Android
| 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 |
| 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) | |
| 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) | |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
Expand Down
1 change: 1 addition & 0 deletions sentry-spring-boot-jakarta/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
57 changes: 57 additions & 0 deletions sentry-spring-boot-jakarta/api/sentry-spring-boot-jakarta.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
public final class io/sentry/spring/boot/jakarta/BuildConfig {
public static final field SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
}

public class io/sentry/spring/boot/jakarta/InAppIncludesResolver : org/springframework/context/ApplicationContextAware {
public fun <init> ()V
public fun resolveInAppIncludes ()Ljava/util/List;
public fun setApplicationContext (Lorg/springframework/context/ApplicationContext;)V
}

public class io/sentry/spring/boot/jakarta/SentryAutoConfiguration {
public fun <init> ()V
}

public class io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfiguration {
public fun <init> ()V
public fun sentryLogbackInitializer (Lio/sentry/spring/boot/jakarta/SentryProperties;)Lio/sentry/spring/boot/jakarta/SentryLogbackInitializer;
}

public class io/sentry/spring/boot/jakarta/SentryProperties : io/sentry/SentryOptions {
public fun <init> ()V
public fun getExceptionResolverOrder ()I
public fun getLogging ()Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;
public fun getReactive ()Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;
public fun getUserFilterOrder ()Ljava/lang/Integer;
public fun isUseGitCommitIdAsRelease ()Z
public fun setExceptionResolverOrder (I)V
public fun setLogging (Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;)V
public fun setReactive (Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;)V
public fun setUseGitCommitIdAsRelease (Z)V
public fun setUserFilterOrder (Ljava/lang/Integer;)V
}

public class io/sentry/spring/boot/jakarta/SentryProperties$Logging {
public fun <init> ()V
public fun getLoggers ()Ljava/util/List;
public fun getMinimumBreadcrumbLevel ()Lorg/slf4j/event/Level;
public fun getMinimumEventLevel ()Lorg/slf4j/event/Level;
public fun isEnabled ()Z
public fun setEnabled (Z)V
public fun setLoggers (Ljava/util/List;)V
public fun setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V
public fun setMinimumEventLevel (Lorg/slf4j/event/Level;)V
}

public class io/sentry/spring/boot/jakarta/SentryProperties$Reactive {
public fun <init> ()V
public fun isThreadLocalAccessorEnabled ()Z
public fun setThreadLocalAccessorEnabled (Z)V
}

public class io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration {
public fun <init> ()V
public fun sentryWebExceptionHandler (Lio/sentry/IHub;)Lio/sentry/spring/jakarta/webflux/SentryWebExceptionHandler;
}

117 changes: 117 additions & 0 deletions sentry-spring-boot-jakarta/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import net.ltgt.gradle.errorprone.errorprone
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.plugin.SpringBootPlugin

plugins {
`java-library`
kotlin("jvm")
jacoco
id(Config.QualityPlugins.errorProne)
id(Config.QualityPlugins.gradleVersions)
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion
id(Config.BuildPlugins.springBoot) version Config.springBoot3Version apply false
}

configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
kotlinOptions.languageVersion = Config.kotlinCompatibleLanguageVersion
}

dependencies {
api(projects.sentry)
api(projects.sentrySpringJakarta)
compileOnly(projects.sentryLogback)
compileOnly(projects.sentryApacheHttpClient5)
compileOnly(Config.Libs.springBoot3Starter)
compileOnly(platform(SpringBootPlugin.BOM_COORDINATES))
compileOnly(projects.sentryGraphql)
compileOnly(Config.Libs.springWeb)
compileOnly(Config.Libs.springWebflux)
compileOnly(Config.Libs.servletApiJakarta)
compileOnly(Config.Libs.springBoot3StarterAop)
compileOnly(Config.Libs.springBoot3StarterSecurity)
compileOnly(Config.Libs.springBoot3StarterGraphql)
compileOnly(Config.Libs.reactorCore)
compileOnly(Config.Libs.contextPropagation)
compileOnly(projects.sentryOpentelemetry.sentryOpentelemetryCore)

annotationProcessor(platform(SpringBootPlugin.BOM_COORDINATES))
annotationProcessor(Config.AnnotationProcessors.springBootAutoConfigure)
annotationProcessor(Config.AnnotationProcessors.springBootConfiguration)

compileOnly(Config.CompileOnly.nopen)
errorprone(Config.CompileOnly.nopenChecker)
errorprone(Config.CompileOnly.errorprone)
errorprone(Config.CompileOnly.errorProneNullAway)
compileOnly(Config.CompileOnly.jetbrainsAnnotations)

// tests
testImplementation(projects.sentryLogback)
testImplementation(projects.sentryApacheHttpClient5)
testImplementation(projects.sentryTestSupport)
testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
testImplementation(Config.TestLibs.mockWebserver)

testImplementation(Config.Libs.okhttp)
testImplementation(Config.Libs.springBoot3Starter)
testImplementation(platform(SpringBootPlugin.BOM_COORDINATES))
testImplementation(Config.Libs.springBoot3StarterTest)
testImplementation(Config.Libs.springBoot3StarterWeb)
testImplementation(Config.Libs.springBoot3StarterWebflux)
testImplementation(Config.Libs.springBoot3StarterSecurity)
testImplementation(Config.Libs.springBoot3StarterAop)
testImplementation(projects.sentryOpentelemetry.sentryOpentelemetryCore)
testImplementation(Config.Libs.contextPropagation)
}

configure<SourceSetContainer> {
test {
java.srcDir("src/test/java")
}
}

jacoco {
toolVersion = Config.QualityPlugins.Jacoco.version
}

tasks.jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(false)
}
}

tasks {
jacocoTestCoverageVerification {
violationRules {
rule { limit { minimum = Config.QualityPlugins.Jacoco.minimumCoverage } }
}
}
check {
dependsOn(jacocoTestCoverageVerification)
dependsOn(jacocoTestReport)
}
}

buildConfig {
useJavaOutput()
packageName("io.sentry.spring.boot.jakarta")
buildConfigField("String", "SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME", "\"${Config.Sentry.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME}\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

val generateBuildConfig by tasks
tasks.withType<JavaCompile>().configureEach {
dependsOn(generateBuildConfig)
options.errorprone {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "io.sentry")
}
}
Original file line number Diff line number Diff line change
@@ -1,57 +0,0 @@
public final class io/sentry/spring/boot/jakarta/BuildConfig {
public static final field SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
}

public class io/sentry/spring/boot/jakarta/InAppIncludesResolver : org/springframework/context/ApplicationContextAware {
public fun <init> ()V
public fun resolveInAppIncludes ()Ljava/util/List;
public fun setApplicationContext (Lorg/springframework/context/ApplicationContext;)V
}

public class io/sentry/spring/boot/jakarta/SentryAutoConfiguration {
public fun <init> ()V
}

public class io/sentry/spring/boot/jakarta/SentryLogbackAppenderAutoConfiguration {
public fun <init> ()V
public fun sentryLogbackInitializer (Lio/sentry/spring/boot/jakarta/SentryProperties;)Lio/sentry/spring/boot/jakarta/SentryLogbackInitializer;
}

public class io/sentry/spring/boot/jakarta/SentryProperties : io/sentry/SentryOptions {
public fun <init> ()V
public fun getExceptionResolverOrder ()I
public fun getLogging ()Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;
public fun getReactive ()Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;
public fun getUserFilterOrder ()Ljava/lang/Integer;
public fun isUseGitCommitIdAsRelease ()Z
public fun setExceptionResolverOrder (I)V
public fun setLogging (Lio/sentry/spring/boot/jakarta/SentryProperties$Logging;)V
public fun setReactive (Lio/sentry/spring/boot/jakarta/SentryProperties$Reactive;)V
public fun setUseGitCommitIdAsRelease (Z)V
public fun setUserFilterOrder (Ljava/lang/Integer;)V
}

public class io/sentry/spring/boot/jakarta/SentryProperties$Logging {
public fun <init> ()V
public fun getLoggers ()Ljava/util/List;
public fun getMinimumBreadcrumbLevel ()Lorg/slf4j/event/Level;
public fun getMinimumEventLevel ()Lorg/slf4j/event/Level;
public fun isEnabled ()Z
public fun setEnabled (Z)V
public fun setLoggers (Ljava/util/List;)V
public fun setMinimumBreadcrumbLevel (Lorg/slf4j/event/Level;)V
public fun setMinimumEventLevel (Lorg/slf4j/event/Level;)V
}

public class io/sentry/spring/boot/jakarta/SentryProperties$Reactive {
public fun <init> ()V
public fun isThreadLocalAccessorEnabled ()Z
public fun setThreadLocalAccessorEnabled (Z)V
}

public class io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration {
public fun <init> ()V
public fun sentryWebExceptionHandler (Lio/sentry/IHub;)Lio/sentry/spring/jakarta/webflux/SentryWebExceptionHandler;
}

48 changes: 2 additions & 46 deletions sentry-spring-boot-starter-jakarta/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins {
jacoco
id(Config.QualityPlugins.errorProne)
id(Config.QualityPlugins.gradleVersions)
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion
id(Config.BuildPlugins.springBoot) version Config.springBoot3Version apply false
}

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

dependencies {
api(projects.sentry)
api(projects.sentrySpringJakarta)
compileOnly(projects.sentryLogback)
compileOnly(projects.sentryApacheHttpClient5)
compileOnly(Config.Libs.springBoot3Starter)
compileOnly(platform(SpringBootPlugin.BOM_COORDINATES))
compileOnly(projects.sentryGraphql)
compileOnly(Config.Libs.springWeb)
compileOnly(Config.Libs.springWebflux)
compileOnly(Config.Libs.servletApiJakarta)
compileOnly(Config.Libs.springBoot3StarterAop)
compileOnly(Config.Libs.springBoot3StarterSecurity)
compileOnly(Config.Libs.springBoot3StarterGraphql)
compileOnly(Config.Libs.reactorCore)
compileOnly(Config.Libs.contextPropagation)
compileOnly(projects.sentryOpentelemetry.sentryOpentelemetryCore)
api(projects.sentrySpringBootJakarta)
api(Config.Libs.springBoot3Starter)

annotationProcessor(platform(SpringBootPlugin.BOM_COORDINATES))
annotationProcessor(Config.AnnotationProcessors.springBootAutoConfigure)
Expand All @@ -49,26 +34,6 @@ dependencies {
errorprone(Config.CompileOnly.errorprone)
errorprone(Config.CompileOnly.errorProneNullAway)
compileOnly(Config.CompileOnly.jetbrainsAnnotations)

// tests
testImplementation(projects.sentryLogback)
testImplementation(projects.sentryApacheHttpClient5)
testImplementation(projects.sentryTestSupport)
testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
testImplementation(Config.TestLibs.mockWebserver)

testImplementation(Config.Libs.okhttp)
testImplementation(Config.Libs.springBoot3Starter)
testImplementation(platform(SpringBootPlugin.BOM_COORDINATES))
testImplementation(Config.Libs.springBoot3StarterTest)
testImplementation(Config.Libs.springBoot3StarterWeb)
testImplementation(Config.Libs.springBoot3StarterWebflux)
testImplementation(Config.Libs.springBoot3StarterSecurity)
testImplementation(Config.Libs.springBoot3StarterAop)
testImplementation(projects.sentryOpentelemetry.sentryOpentelemetryCore)
testImplementation(Config.Libs.contextPropagation)
}

configure<SourceSetContainer> {
Expand Down Expand Up @@ -100,16 +65,7 @@ tasks {
}
}

buildConfig {
useJavaOutput()
packageName("io.sentry.spring.boot.jakarta")
buildConfigField("String", "SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME", "\"${Config.Sentry.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME}\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

val generateBuildConfig by tasks
tasks.withType<JavaCompile>().configureEach {
dependsOn(generateBuildConfig)
options.errorprone {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "io.sentry")
Expand Down
Loading

0 comments on commit 7cdf121

Please sign in to comment.