Skip to content

build(samples): Remove outputs.upToDateWhen { false } from systemTest tasks#5522

Merged
runningcode merged 3 commits into
mainfrom
no/remove-uptodatewhen-systemtest
Jun 23, 2026
Merged

build(samples): Remove outputs.upToDateWhen { false } from systemTest tasks#5522
runningcode merged 3 commits into
mainfrom
no/remove-uptodatewhen-systemtest

Conversation

@runningcode

@runningcode runningcode commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Removes outputs.upToDateWhen { false } from the systemTest tasks in the sentry-samples/* modules and replaces it with proper Gradle input tracking via a new io.sentry.systemtest convention plugin.

The system tests launch the packaged sample app (shadowJar/bootJar/war) from build/libs as a separate process — it is not on the test classpath. With only outputs.upToDateWhen { false } removed, Gradle would compute up-to-date purely from the test classes and runtime classpath, so a separate jar build could refresh the artifact while systemTest was skipped, meaning the assertions never ran against the rebuilt sample.

Rather than repeat the wiring in all 22 sample build files, it lives in one build-logic convention plugin (build-logic/src/main/kotlin/io.sentry.systemtest.gradle.kts), following the existing io.sentry.spotless / io.sentry.javadoc pattern. Each sample applies id("io.sentry.systemtest"). The plugin auto-detects the packaging task with precedence war → shadowJar → bootJar (mirroring test/system-test-runner.py) and declares its archive as a systemTest input:

tasks.matching { it.name == "systemTest" }.configureEach {
  val archiveTask =
    listOf("war", "shadowJar", "bootJar").firstOrNull { it in tasks.names }
      ?: throw GradleException("…none of war/shadowJar/bootJar exist…")
  // Declaring the archive as an input also wires the dependency on its producing task.
  inputs.files(tasks.named(archiveTask))
    .withPropertyName("appArchive")
    .withNormalizer(ClasspathNormalizer::class.java)
  …
}

OpenTelemetry agent. The agent-based OTel samples are also launched with -javaagent:<sentry-opentelemetry-agent>, started outside the test JVM and likewise untracked. The plugin exposes a usesOpenTelemetryAgent opt-in (sentrySystemTest { usesOpenTelemetryAgent = true }); the three agent samples enable it and the agent jar is tracked as a content input. The runner already builds and launches the agent before invoking the task, so it is tracked by path (no cross-project task dependency), which keeps it configuration-on-demand and configuration-cache compatible.

Notes on Gradle best practices:

  • tasks.matching { … }.configureEach + it in tasks.names + tasks.named(…) are all lazy — no eager task realization (configuration avoidance preserved).
  • No afterEvaluate.
  • Misconfiguration fails loudly (GradleException) rather than silently skipping the input.
  • Configuration cache verified: entry stored then reused across runs with no problems.

💡 Motivation and Context

outputs.upToDateWhen { false } disabled up-to-date checks and build-cache reuse for the systemTest tasks because the launched JAR/WAR (and OTel agent) were not modeled as task inputs. This models those inputs properly — in one place — instead of disabling incremental builds wholesale.

💚 How did you test it?

  • ./gradlew spotlessApply / spotlessCheck pass; the convention plugin compiles and applies.
  • ./gradlew --dry-run --configuration-cache :sentry-samples:<module>:systemTest for a console (shadowJar), Spring Boot 2 (shadowJar), Spring Boot 4 (bootJar), and Tomcat (war) module confirms the packaging task is wired ahead of systemTest; agent modules additionally track the agent jar. Configuration cache stores and reuses cleanly.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

#skip-changelog

… tasks

The systemTest tasks in the sample modules forced Gradle to always treat
their outputs as out of date, disabling up-to-date checks and build cache
reuse. Removing this lets Gradle rely on its normal input/output tracking
for the Test tasks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sentry

sentry Bot commented Jun 10, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.44.1 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode runningcode marked this pull request as ready for review June 10, 2026 08:48
Comment thread sentry-samples/sentry-samples-console/build.gradle.kts

@adinauer adinauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Thanks! Approving so you can merge once the comment is addressed.

@runningcode runningcode force-pushed the no/remove-uptodatewhen-systemtest branch 2 times, most recently from 9724cf1 to e1d4454 Compare June 22, 2026 15:09

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e1d4454. Configure here.

Comment thread build-logic/src/main/kotlin/io.sentry.systemtest.gradle.kts
The system tests launch the packaged sample (war/shadowJar/bootJar) from
build/libs as a separate process, so the archive is a real input to the
systemTest task even though it is not on the test classpath. Without it,
removing outputs.upToDateWhen { false } would let Gradle mark systemTest
up-to-date while a separate jar build refreshed the artifact, skipping
verification against the rebuilt sample.

Move that wiring into a single io.sentry.systemtest convention plugin in
build-logic instead of repeating it in every sample build file. The
plugin auto-detects the packaging task (war, else shadowJar, else
bootJar), mirroring the selection in test/system-test-runner.py, and
declares its archive as an input and dependency. Each sample just
applies the plugin.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@runningcode runningcode force-pushed the no/remove-uptodatewhen-systemtest branch from e1d4454 to 1357435 Compare June 22, 2026 15:12
The agent-based OpenTelemetry samples are launched by the runner with
-javaagent:<sentry-opentelemetry-agent>, started outside the test JVM.
That jar is not on the test classpath nor one of the app archives, so
without tracking it systemTest could stay up-to-date and be skipped
while the runner launches a newer agent.

Add a usesOpenTelemetryAgent opt-in to the io.sentry.systemtest plugin;
the three agent samples enable it and the agent jar is then tracked as a
content input. The runner already builds and launches the agent before
invoking the task, so it is tracked by path without a cross-project task
dependency, which keeps it configuration-on-demand and configuration
cache compatible.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@runningcode runningcode force-pushed the no/remove-uptodatewhen-systemtest branch from e0dbf30 to 06b56f2 Compare June 23, 2026 07:52
@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 315.08 ms 377.51 ms 62.43 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
18c0bc2 306.73 ms 349.77 ms 43.03 ms
0eaac1e 316.82 ms 357.34 ms 40.52 ms
d15471f 303.49 ms 439.08 ms 135.59 ms
fc5ccaf 276.52 ms 370.46 ms 93.93 ms
e2dce0b 308.96 ms 360.10 ms 51.14 ms
5b1a06b 352.27 ms 413.70 ms 61.43 ms
37ec571 366.04 ms 424.28 ms 58.23 ms
9fbb112 361.43 ms 427.57 ms 66.14 ms
bbc35bb 324.88 ms 425.73 ms 100.85 ms
ff8eea4 313.42 ms 337.08 ms 23.66 ms

App size

Revision Plain With Sentry Diff
18c0bc2 1.58 MiB 2.13 MiB 557.33 KiB
0eaac1e 1.58 MiB 2.19 MiB 619.17 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
e2dce0b 0 B 0 B 0 B
5b1a06b 0 B 0 B 0 B
37ec571 0 B 0 B 0 B
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
bbc35bb 1.58 MiB 2.12 MiB 553.01 KiB
ff8eea4 1.58 MiB 2.28 MiB 718.64 KiB

@runningcode runningcode merged commit f982bad into main Jun 23, 2026
68 checks passed
@runningcode runningcode deleted the no/remove-uptodatewhen-systemtest branch June 23, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants