Skip to content

Commit c78db42

Browse files
runningcodeclaude
andcommitted
build(samples): Move the JVM samples to their own build
The 28 JVM samples are now a standalone Gradle build in sentry-samples that includes the SDK build, like the Android sample and the Android integration tests. They depend on io.sentry:* coordinates, which Gradle substitutes with the SDK's projects. The SDK build doesn't include them back, so the Spring Boot, gretty and shadow plugins the samples apply no longer load in the SDK build. The three bootRunWithAgent tasks find the agent jar from the repository root and take the SDK version from the catalog, since the samples build has its own root directory and gradle.properties. With no samples or integration tests left in the SDK build, its apiValidation list and the name filters that skipped them for publishing and CodeQL go too. Root check and spotlessApply no longer reach the samples, so preMerge runs this build's check, which covers what the root check ran for them: compilation, jars and spotless. The format workflow runs its spotlessApply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 76332ce commit c78db42

37 files changed

Lines changed: 323 additions & 213 deletions

File tree

‎.cursor/rules/new_module.mdc‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,10 @@ the release that first ships it. All of the following have to be merged **before
3131

3232
2. Add the module to the include list in `settings.gradle.kts`
3333

34-
If adding a `sentry-samples` module, also add it to the `ignoredProjects` list in the root `build.gradle.kts`:
35-
36-
```kotlin
37-
ignoredProjects.addAll(
38-
listOf(
39-
// ... existing projects ...
40-
"sentry-samples-{module-name}"
41-
)
42-
)
43-
```
34+
If adding a sample, add it to the include list in `sentry-samples/settings.gradle.kts` instead. The
35+
samples are a separate Gradle build that includes the SDK build, so a sample depends on
36+
`"io.sentry:sentry-{module-name}:$sentryVersion"` (with `val sentryVersion =
37+
libs.versions.sentry.get()`), and Gradle substitutes the SDK's project for it.
4438

4539
3. Add a `SENTRY_{MODULE}_SDK_NAME` constant to the `Config.Sentry` block in
4640
`buildSrc/src/main/java/Config.kt`:

‎.github/workflows/format-code.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- name: Format with spotlessApply
2727
run: |
2828
./gradlew spotlessApply
29+
./gradlew -p sentry-samples spotlessApply
2930
./gradlew -p sentry-samples/sentry-samples-android spotlessApply
3031
./gradlew -p sentry-android-integration-tests spotlessApply
3132

‎AGENTS.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ resolves the per-module test task, including integration test suites, for you.
6767

6868
# Build the Android sample, a separate Gradle build that includes this one
6969
./gradlew -p sentry-samples/sentry-samples-android assembleDebug
70+
71+
# Build the JVM samples, another separate Gradle build that includes this one
72+
./gradlew -p sentry-samples assemble
7073
```
7174

7275
## Development Workflow Rules
@@ -113,7 +116,7 @@ The repository is organized into multiple modules:
113116

114117
### Utility Modules
115118
- **`sentry-test-support`** - Shared test utilities, including `MockSentryServer` and envelope matchers
116-
- **`sentry-samples`** - Example applications. `sentry-samples-android` is a separate Gradle build that includes this one, so root tasks such as `check` and `spotlessApply` don't reach it
119+
- **`sentry-samples`** - Example applications, in two separate Gradle builds that include this one: `sentry-samples` (JVM) and `sentry-samples/sentry-samples-android`. Root tasks such as `check` and `spotlessApply` don't reach them, and `sentry-android-integration-tests` is a separate build too
117120
- **`sentry-bom`** - Bill of Materials for dependency management
118121

119122
### Key Architectural Patterns

‎Makefile‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.PHONY: all clean compile javadocs dryRelease update checkFormat api assembleUiTestRelease assembleUiTestCriticalRelease runUiTestCritical check checkSampleAndroid checkIntegrationTests preMerge publish
1+
.PHONY: all clean compile javadocs dryRelease update checkFormat api assembleUiTestRelease assembleUiTestCriticalRelease runUiTestCritical check checkSamples checkSampleAndroid checkIntegrationTests preMerge publish
22

33
all: stop clean javadocs compile
44
assembleUiTests: assembleUiTestRelease
5-
preMerge: check checkSampleAndroid checkIntegrationTests
5+
preMerge: check checkSamples checkSampleAndroid checkIntegrationTests
66
publish: clean dryRelease
77

88
# deep clean
@@ -29,6 +29,7 @@ update:
2929
# Spotless check's code
3030
checkFormat:
3131
./gradlew spotlessJavaCheck spotlessKotlinCheck
32+
./gradlew -p sentry-samples spotlessJavaCheck spotlessKotlinCheck
3233
./gradlew -p sentry-samples/sentry-samples-android spotlessJavaCheck spotlessKotlinCheck
3334
./gradlew -p sentry-android-integration-tests spotlessJavaCheck spotlessKotlinCheck
3435

@@ -52,6 +53,10 @@ runUiTestCritical:
5253
check:
5354
./gradlew check
5455

56+
# The samples are separate builds, so the root `check` doesn't reach them
57+
checkSamples:
58+
./gradlew -p sentry-samples check
59+
5560
# The Android sample is a separate build, so the root `check` doesn't reach it
5661
checkSampleAndroid:
5762
./gradlew -p sentry-samples/sentry-samples-android check

‎build.gradle.kts‎

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,6 @@ apiValidation {
5050
)
5151
ignoredProjects.addAll(
5252
listOf(
53-
"sentry-samples-console",
54-
"sentry-samples-console-opentelemetry-noagent",
55-
"sentry-samples-jul",
56-
"sentry-samples-log4j2",
57-
"sentry-samples-logback",
58-
"sentry-samples-openfeign",
59-
"sentry-samples-servlet",
60-
"sentry-samples-spring",
61-
"sentry-samples-spring-jakarta",
62-
"sentry-samples-spring-7",
63-
"sentry-samples-spring-boot",
64-
"sentry-samples-spring-boot-opentelemetry",
65-
"sentry-samples-spring-boot-opentelemetry-noagent",
66-
"sentry-samples-spring-boot-jakarta",
67-
"sentry-samples-spring-boot-jakarta-log4j2",
68-
"sentry-samples-spring-boot-jakarta-opentelemetry",
69-
"sentry-samples-spring-boot-jakarta-opentelemetry-noagent",
70-
"sentry-samples-spring-boot-webflux",
71-
"sentry-samples-spring-boot-webflux-jakarta",
72-
"sentry-samples-spring-boot-4",
73-
"sentry-samples-spring-boot-4-log4j2",
74-
"sentry-samples-spring-boot-4-opentelemetry",
75-
"sentry-samples-spring-boot-4-opentelemetry-noagent",
76-
"sentry-samples-spring-boot-4-otlp",
77-
"sentry-samples-spring-boot-4-webflux",
78-
"sentry-samples-ktor-client",
79-
"sentry-samples-netflix-dgs",
80-
"sentry-samples-console-otlp",
8153
"sentry-test-support"
8254
)
8355
)
@@ -113,7 +85,7 @@ subprojects {
11385
}
11486
}
11587

116-
if (!this.name.contains("sample") && !this.name.contains("integration-tests") && this.name != "sentry-test-support") {
88+
if (this.name != "sentry-test-support") {
11789
apply<DistributionPlugin>()
11890
apply<com.vanniktech.maven.publish.MavenPublishPlugin>()
11991

@@ -187,9 +159,7 @@ subprojects {
187159
tasks.register("buildForCodeQL") {
188160
subprojects
189161
.filter {
190-
!it.displayName.contains("sample") &&
191-
!it.displayName.contains("integration-tests") &&
192-
!it.displayName.contains("bom") &&
162+
!it.displayName.contains("bom") &&
193163
it.name != "sentry-opentelemetry"
194164
}
195165
.forEach { proj ->

‎sentry-samples/build.gradle.kts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Loads the shared plugins once for every sample, so they all share one classpath. The Spring Boot
2+
// plugin is applied in each sample instead, because the samples use different versions of it.
3+
plugins {
4+
alias(libs.plugins.kotlin.jvm) apply false
5+
alias(libs.plugins.kotlin.spring) apply false
6+
alias(libs.plugins.spring.dependency.management) apply false
7+
alias(libs.plugins.gradle.versions) apply false
8+
id("io.sentry.spotless") apply false
9+
id("io.sentry.jdk-target") apply false
10+
}
11+
12+
subprojects {
13+
apply(plugin = "io.sentry.spotless")
14+
apply(plugin = "io.sentry.jdk-target")
15+
}

‎sentry-samples/gradle.properties‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Gradle properties are per build, so this repeats what the samples need from the SDK build's
2+
# gradle.properties. settings.gradle.kts reads the SDK version from that file.
3+
4+
org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=2g -XX:+CrashOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC
5+
org.gradle.caching=true
6+
org.gradle.parallel=true
7+
org.gradle.configureondemand=true
8+
org.gradle.configuration-cache=true
9+
org.gradle.configuration-cache.parallel=true
10+
11+
kotlin.stdlib.default.dependency=false
12+
13+
systemProp.org.gradle.internal.http.socketTimeout=120000

‎sentry-samples/sentry-samples-console-opentelemetry-noagent/build.gradle.kts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ plugins {
55
alias(libs.plugins.shadow)
66
}
77

8+
val sentryVersion = libs.versions.sentry.get()
9+
810
application { mainClass.set("io.sentry.samples.console.Main") }
911

1012
dependencies {
11-
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentless)
12-
implementation(projects.sentryAsyncProfiler)
13+
implementation("io.sentry:sentry-opentelemetry-agentless:$sentryVersion")
14+
implementation("io.sentry:sentry-async-profiler:$sentryVersion")
1315
}
1416

1517
// Configure the Shadow JAR (executable JAR with all dependencies)

‎sentry-samples/sentry-samples-console-otlp/build.gradle.kts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ plugins {
55
alias(libs.plugins.shadow)
66
}
77

8+
val sentryVersion = libs.versions.sentry.get()
9+
810
application { mainClass.set("io.sentry.samples.console.Main") }
911

1012
dependencies {
11-
implementation(projects.sentryOpentelemetry.sentryOpentelemetryOtlp)
12-
implementation(projects.sentryAsyncProfiler)
13+
implementation("io.sentry:sentry-opentelemetry-otlp:$sentryVersion")
14+
implementation("io.sentry:sentry-async-profiler:$sentryVersion")
1315
implementation(libs.otel.semconv)
1416
implementation(libs.otel.semconv.incubating)
1517
implementation(libs.otel.exporter.logging)

‎sentry-samples/sentry-samples-console/build.gradle.kts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ plugins {
55
alias(libs.plugins.shadow)
66
}
77

8+
val sentryVersion = libs.versions.sentry.get()
9+
810
application { mainClass.set("io.sentry.samples.console.Main") }
911

1012
dependencies {
11-
implementation(projects.sentry)
12-
implementation(projects.sentryAsyncProfiler)
13-
implementation(projects.sentryJcache)
14-
implementation(projects.sentryKafka)
13+
implementation("io.sentry:sentry:$sentryVersion")
14+
implementation("io.sentry:sentry-async-profiler:$sentryVersion")
15+
implementation("io.sentry:sentry-jcache:$sentryVersion")
16+
implementation("io.sentry:sentry-kafka:$sentryVersion")
1517
implementation(libs.jcache)
1618
implementation(libs.caffeine.jcache)
1719
implementation(libs.kafka.clients)

0 commit comments

Comments
 (0)