Skip to content

Skip bootstrap.yml merge when spring-cloud-starter-bootstrap is present#954

Merged
Jenson3210 merged 6 commits intomainfrom
skip-bootstrap-merge-with-cloud-starter
Mar 5, 2026
Merged

Skip bootstrap.yml merge when spring-cloud-starter-bootstrap is present#954
Jenson3210 merged 6 commits intomainfrom
skip-bootstrap-merge-with-cloud-starter

Conversation

@Jenson3210
Copy link
Contributor

@Jenson3210 Jenson3210 commented Mar 4, 2026

Summary

  • Skip MergeBootstrapYamlWithApplicationYaml when spring-cloud-starter-bootstrap is a project dependency
  • Check both Maven (MavenResolutionResult) and Gradle (GradleProject) markers for the dependency
  • Add test verifying no changes when the dependency is present

Problem

The MergeBootstrapYamlWithApplicationYaml recipe unconditionally merges bootstrap.yml into application.yml. However, in Spring Boot 2.4 the bootstrap context was only disabled by default — projects that include spring-cloud-starter-bootstrap as a dependency still load bootstrap files normally and should not have them merged away.

See the Spring Cloud Config Client docs — to use the legacy bootstrap way of connecting to Config Server, bootstrap must be enabled via the spring-cloud-starter-bootstrap starter.

Solution

During the scan phase, check each source file's build tool markers for org.springframework.cloud:spring-cloud-starter-bootstrap. If found, the recipe skips entirely — no merging, no file generation, no file deletion.

Test plan

  • Existing tests pass
  • New test doNotMergeWhenSpringCloudStarterBootstrapPresent added

Fixes moderneinc/customer-requests#1951

In Spring Boot 2.4, the bootstrap context is disabled by default but
continues to work if spring-cloud-starter-bootstrap is on the classpath.
The MergeBootstrapYamlWithApplicationYaml recipe now checks for this
dependency in both Maven and Gradle projects and skips the merge when
it is present, avoiding incorrect migration of projects that still
rely on the bootstrap context.

Fixes moderneinc/customer-requests#1951
@Jenson3210 Jenson3210 requested a review from timtebeek March 5, 2026 08:26
@Jenson3210 Jenson3210 marked this pull request as ready for review March 5, 2026 08:26
@Jenson3210 Jenson3210 requested a review from MBoegers March 5, 2026 10:21
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Mar 5, 2026
@Jenson3210 Jenson3210 merged commit fc60b5c into main Mar 5, 2026
1 check passed
@Jenson3210 Jenson3210 deleted the skip-bootstrap-merge-with-cloud-starter branch March 5, 2026 10:50
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants