Skip to content

Commit c9a84ee

Browse files
runningcodeclaude
andauthored
build(samples): [Sample Tests 47] Move the JVM samples to their own build (#6394)
* 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, 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> * build(samples): Link the JVM samples' Gradle files to the SDK build's gradle.properties, gradlew, gradle/wrapper and gradle/gradle-daemon-jvm.properties are now symlinks to the SDK build's files, as in the Android sample and integration test builds. The copied gradle.properties had drifted from the root one (-Xmx6g and CrashOnOutOfMemoryError), and the build had no wrapper or daemon JDK pin. The settings read the SDK version from the shared versionName property, use the root build's Develocity plugin version, and include each sample on its own line, matching the other separate builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Apply the convention plugins in each JVM sample Each sample applies io.sentry.spotless and io.sentry.jdk-target in its own plugins block, as the modules of the other separate builds do, instead of the root script applying them to every subproject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(samples): Check the JVM samples in the Samples workflow The JVM samples' check runs as its own job in the Samples workflow, like the other separate builds, instead of through checkSamples in make preMerge, so it no longer lengthens the required Build job. Dependabot scans their build too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build: Drop the root's Spring dependency-management declaration With the JVM samples in their own build, no project in the SDK build applies io.spring.dependency-management. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Drop the comment on the JVM samples' root plugins Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Drop the header comment from the JVM samples' settings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(samples): Declare the servlet sample's SDK version before using it The dependencies block read sentryVersion before its declaration ran, so the sample asked for io.sentry:sentry-servlet:null. The composite build substitutes the SDK project by group and name, which hid it, but resolving published artifacts would fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c22fe1a commit c9a84ee

41 files changed

Lines changed: 288 additions & 183 deletions

File tree

Some content is hidden

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

‎.cursor/rules/new_module.mdc‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,11 @@ 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 an `include("…")` line for it to `sentry-samples/settings.gradle.kts`
35+
instead, and apply `id("io.sentry.spotless")` and `id("io.sentry.jdk-target")` in its `plugins`
36+
block. The samples are a separate Gradle build that includes the SDK build, so a sample depends on
37+
`"io.sentry:sentry-{module-name}:$sentryVersion"` (with `val sentryVersion =
38+
libs.versions.sentry.get()`), and Gradle substitutes the SDK's project for it.
4439

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

‎.github/dependabot.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ updates:
1212
- "/"
1313
- "/sentry-samples/sentry-samples-android"
1414
- "/sentry-android-integration-tests"
15+
- "/sentry-samples"
1516
registries:
1617
- gradle-plugin-portal
1718
schedule:

‎.github/workflows/samples.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
path: sentry-samples/sentry-samples-android
2525
- name: sentry-android-integration-tests
2626
path: sentry-android-integration-tests
27+
- name: sentry-samples
28+
path: sentry-samples
2729

2830
steps:
2931
- name: Checkout Repo

‎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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ update:
2828
# Spotless formats the code. The root spotlessApply doesn't reach the separate builds.
2929
format:
3030
./gradlew spotlessApply
31+
./gradlew -p sentry-samples spotlessApply
3132
./gradlew -p sentry-samples/sentry-samples-android spotlessApply
3233
./gradlew -p sentry-android-integration-tests spotlessApply
3334

3435
# Spotless check's code
3536
checkFormat:
3637
./gradlew spotlessJavaCheck spotlessKotlinCheck
38+
./gradlew -p sentry-samples spotlessJavaCheck spotlessKotlinCheck
3739
./gradlew -p sentry-samples/sentry-samples-android spotlessJavaCheck spotlessKotlinCheck
3840
./gradlew -p sentry-android-integration-tests spotlessJavaCheck spotlessKotlinCheck
3941

‎build.gradle.kts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ plugins {
1717
alias(libs.plugins.kotlin.compose) apply false
1818
alias(libs.plugins.errorprone) apply false
1919
alias(libs.plugins.gradle.versions) apply false
20-
alias(libs.plugins.spring.dependency.management) apply false
2120
id("io.sentry.javadoc.aggregate")
2221
alias(libs.plugins.android.application) apply false
2322
}
@@ -51,9 +50,7 @@ allprojects {
5150
tasks.register("buildForCodeQL") {
5251
subprojects
5352
.filter {
54-
!it.displayName.contains("sample") &&
55-
!it.displayName.contains("integration-tests") &&
56-
!it.displayName.contains("bom") &&
53+
!it.displayName.contains("bom") &&
5754
it.name != "sentry-opentelemetry"
5855
}
5956
.forEach { proj ->

‎sentry-samples/build.gradle.kts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
alias(libs.plugins.kotlin.jvm) apply false
3+
alias(libs.plugins.kotlin.spring) apply false
4+
alias(libs.plugins.spring.dependency.management) apply false
5+
alias(libs.plugins.gradle.versions) apply false
6+
id("io.sentry.spotless") apply false
7+
id("io.sentry.jdk-target") apply false
8+
}

‎sentry-samples/gradle.properties‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../gradle.properties
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../gradle/gradle-daemon-jvm.properties

‎sentry-samples/gradle/wrapper‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../gradle/wrapper

0 commit comments

Comments
 (0)