fix(build): remove Spring Boot 2 Gradle plugin for Gradle 9 compatibility#5263
Draft
adinauer wants to merge 6 commits intodeps/scripts/update-gradle.shfrom
Draft
fix(build): remove Spring Boot 2 Gradle plugin for Gradle 9 compatibility#5263adinauer wants to merge 6 commits intodeps/scripts/update-gradle.shfrom
adinauer wants to merge 6 commits intodeps/scripts/update-gradle.shfrom
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
Sentry Build Distribution
|
…lity The Spring Boot 2.7.x Gradle plugin uses removed Gradle APIs (LenientConfiguration.getFiles()) that are incompatible with Gradle 9. Library modules (sentry-spring, sentry-spring-boot, sentry-spring-boot-starter): - Replace SpringBootPlugin.BOM_COORDINATES with direct BOM reference via version catalog (libs.springboot2.bom) - Remove the 'apply false' plugin declaration entirely Sample apps (spring-boot, webflux, otel, netflix-dgs): - Replace Spring Boot plugin with Shadow plugin for fat JAR creation - Add application plugin for main class configuration - Use platform(libs.springboot2.bom) for dependency version management - Configure shadow JAR to merge Spring metadata files - Replace BootRun task with JavaExec in otel sample
…erge Shadow plugin 9.x defaults to DuplicatesStrategy.EXCLUDE, which drops duplicate META-INF/spring.factories entries before transformers can merge them. Setting INCLUDE allows the AppendingTransformer to see all entries and properly concatenate spring.factories from all JARs. Without this, the shadow JAR only contains spring.factories from a single dependency, causing Spring Boot auto-configuration to fail (e.g. missing RestTemplateBuilder, no embedded web server).
52ced43 to
9dd4f2f
Compare
- Auto-detect shadowJar vs bootJar build task based on build.gradle.kts - Add fallback HTTP readiness check for shadow JAR apps that lack actuator endpoints (actuator web endpoints don't work in flat JARs) - Append spring-autoconfigure-metadata.properties in shadow JAR config
Shadow 9.x enforces duplicatesStrategy before transformers run, so DuplicatesStrategy.FAIL prevents mergeServiceFiles from merging inst/META-INF/services/ files that exist in both the upstream OTel agent JAR and the isolated distro libs. Switching to INCLUDE lets the transformer see all duplicates and merge them correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Shadow 9.x DuplicatesStrategy fix
Shadow 9.x enforces
DuplicatesStrategybefore transformers (likemergeServiceFilesandAppendingTransformer) can process duplicates. This meansFAILorEXCLUDEprevents service files and Spring metadata from being merged. All shadow JAR tasks now useDuplicatesStrategy.INCLUDEto let transformers see all duplicate entries.Spring Boot 2 Gradle plugin removal
Remove the Spring Boot 2 Gradle plugin (
org.springframework.bootv2.7.18) which is incompatible with Gradle 9 due to use of removed APILenientConfiguration.getFiles().Library modules (
sentry-spring,sentry-spring-boot,sentry-spring-boot-starter):apply falseto accessSpringBootPlugin.BOM_COORDINATESlibs.springboot2.bom)Sample apps (
spring-boot,webflux,otel,netflix-dgs):io.spring.dependency-managementwith Shadow plugin (com.gradleup.shadow) for fat JAR creationapplicationplugin for main class configurationplatform(libs.springboot2.bom)for dependency version managementDuplicatesStrategy.INCLUDE+append()to merge Spring metadata files (spring.factories,spring.handlers,spring.schemas,spring-autoconfigure-metadata.properties)BootRuntask in otel sample replaced with standardJavaExecOTel agent shadow JAR fix
sentry-opentelemetry-agentshadowJarswitched fromDuplicatesStrategy.FAILtoINCLUDEsomergeServiceFilescan mergeinst/META-INF/services/from the upstream OTel agent and the distro libsSystem test runner
shadowJarvsbootJarbuild task per moduleNote: Spring Boot 3 and 4 plugins are unaffected — they are already Gradle 9 compatible.
💡 Motivation and Context
Stacked on top of #5063. The Spring Boot 2.7.x Gradle plugin uses
LenientConfiguration.getFiles()which was removed in Gradle 9, causingbootJarandbuildtasks to fail. Shadow 9.x changed duplicate handling behavior requiringDuplicatesStrategy.INCLUDEfor transformer-based merging to work.💚 How did you test it?
./gradlew :sentry-spring:compileJava :sentry-spring-boot:compileJava :sentry-spring-boot-starter:compileJava— passes./gradlew :sentry-spring:test— passesspring.factories(170+ lines)./gradlew :sentry-opentelemetry:sentry-opentelemetry-agent:shadowJar— passes, service files properly merged📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Other Gradle 9 compatibility fixes in the parent PR.
#skip-changelog