@@ -15,25 +15,37 @@ group = "io.sentry.sample.spring-boot"
1515
1616version = " 0.0.1-SNAPSHOT"
1717
18- java.sourceCompatibility = JavaVersion .VERSION_17
18+ java.sourceCompatibility = JavaVersion .VERSION_11
1919
20- java.targetCompatibility = JavaVersion .VERSION_17
20+ java.targetCompatibility = JavaVersion .VERSION_11
2121
2222repositories { mavenCentral() }
2323
24+ fun springBoot2SupportsOptionalIntegrations (): Boolean {
25+ val version = libs.versions.springboot2.get().removeSuffix(" .RELEASE" )
26+ val parts = version.split(" ." ).map { it.toIntOrNull() ? : 0 }
27+ val major = parts.getOrElse(0 ) { 0 }
28+ val minor = parts.getOrElse(1 ) { 0 }
29+ return major > 2 || (major == 2 && minor >= 7 )
30+ }
31+
32+ val includeGraphql =
33+ ! project.hasProperty(" excludeGraphql" ) && springBoot2SupportsOptionalIntegrations()
34+ val includeKafka = ! project.hasProperty(" excludeKafka" ) && springBoot2SupportsOptionalIntegrations()
35+
2436configure<JavaPluginExtension > {
25- sourceCompatibility = JavaVersion .VERSION_17
26- targetCompatibility = JavaVersion .VERSION_17
37+ sourceCompatibility = JavaVersion .VERSION_11
38+ targetCompatibility = JavaVersion .VERSION_11
2739}
2840
2941tasks.withType<KotlinCompile >().configureEach {
30- compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget .JVM_17
42+ compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget .JVM_11
3143}
3244
3345tasks.withType<KotlinCompile >().configureEach {
3446 kotlin {
3547 compilerOptions.freeCompilerArgs = listOf (" -Xjsr305=strict" )
36- compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget .JVM_17
48+ compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget .JVM_11
3749 }
3850}
3951
@@ -43,7 +55,9 @@ dependencies {
4355 implementation(libs.springboot.starter)
4456 implementation(libs.springboot.starter.actuator)
4557 implementation(libs.springboot.starter.aop)
46- implementation(libs.springboot.starter.graphql)
58+ if (includeGraphql) {
59+ implementation(libs.springboot.starter.graphql)
60+ }
4761 implementation(libs.springboot.starter.jdbc)
4862 implementation(libs.springboot.starter.quartz)
4963 implementation(libs.springboot.starter.security)
@@ -55,14 +69,17 @@ dependencies {
5569 implementation(kotlin(Config .kotlinStdLib, KotlinCompilerVersion .VERSION ))
5670 implementation(projects.sentrySpringBootStarter)
5771 implementation(projects.sentryLogback)
58- implementation(projects.sentryGraphql)
72+ if (includeGraphql) {
73+ implementation(projects.sentryGraphql)
74+ }
5975 implementation(projects.sentryQuartz)
6076 implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentlessSpring)
6177 implementation(projects.sentryAsyncProfiler)
6278
63- // kafka
64- implementation(libs.spring.kafka2)
65- implementation(projects.sentryKafka)
79+ if (includeKafka) {
80+ implementation(libs.spring.kafka2)
81+ implementation(projects.sentryKafka)
82+ }
6683
6784 // database query tracing
6885 implementation(projects.sentryJdbc)
@@ -103,7 +120,19 @@ tasks.jar {
103120
104121tasks.startScripts { dependsOn(tasks.shadowJar) }
105122
106- configure<SourceSetContainer > { test { java.srcDir(" src/test/java" ) } }
123+ configure<SourceSetContainer > {
124+ main {
125+ if (! includeGraphql) {
126+ java.exclude(" **/graphql/**" )
127+ resources.exclude(" graphql/**" )
128+ }
129+ if (! includeKafka) {
130+ java.exclude(" **/queues/kafka/**" )
131+ resources.exclude(" application-kafka.properties" )
132+ }
133+ }
134+ test { java.srcDir(" src/test/java" ) }
135+ }
107136
108137tasks.register<Test >(" systemTest" ).configure {
109138 group = " verification"
@@ -121,7 +150,15 @@ tasks.register<Test>("systemTest").configure {
121150 minHeapSize = " 128m"
122151 maxHeapSize = " 1g"
123152
124- filter { includeTestsMatching(" io.sentry.systemtest*" ) }
153+ filter {
154+ includeTestsMatching(" io.sentry.systemtest*" )
155+ if (! includeGraphql) {
156+ excludeTestsMatching(" io.sentry.systemtest.Graphql*" )
157+ }
158+ if (! includeKafka) {
159+ excludeTestsMatching(" io.sentry.systemtest.Kafka*" )
160+ }
161+ }
125162}
126163
127164tasks.named(" test" ).configure {
0 commit comments