Preserve imported BOM precedence in SortDependencies - #8508
Open
martinfrancois wants to merge 6 commits into
Open
Preserve imported BOM precedence in SortDependencies#8508martinfrancois wants to merge 6 commits into
SortDependencies#8508martinfrancois wants to merge 6 commits into
Conversation
Open
4 tasks
martinfrancois
force-pushed
the
agent/repro-sort-dependencies-bom-precedence
branch
from
August 15, 2026 18:49
89ae0f9 to
875836e
Compare
2 tasks
martinfrancois
force-pushed
the
agent/repro-sort-dependencies-bom-precedence
branch
from
August 15, 2026 22:51
364ebe3 to
b574ac0
Compare
martinfrancois
marked this pull request as ready for review
August 17, 2026 08:08
Replace the hand-rolled profile activation and property precedence resolver with ResolvedPom value resolution, keeping the conservative treatment of placeholders the effective model cannot resolve. Rework the tests that only existed to exercise that resolver so they assert the simplified contract instead.
…mparison The CDATA existed only to exercise a trim() that the XML parser makes unnecessary; surrounding whitespace never reaches CharData text. Compare type and scope the way MavenVisitor.isManagedDependencyImportTag does.
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.
Suggested review order: 1 of 52 (Score: 10)
Review first: None - this is the first item in the queue.
What's changed?
Preserves the positions of imported BOM dependencies when
SortDependenciessorts Maven dependencies. Other dependencies still sort around those fixed positions, and comments remain attached to their original dependency.What's your motivation?
Recipe:
org.openrewrite.maven.SortDependencies.I found this by running
org.openrewrite.maven.SortDependenciesfromorg.openrewrite:rewrite-maven:8.87.0onpom.xmlin Symphony-Trello ata8013f27. I reproduced the same result on that exact checkout with the latest released recipe artifact,org.openrewrite:rewrite-maven:8.90.0, usingorg.openrewrite.maven:rewrite-maven-plugin:6.46.1.Before
Actual after the recipe
Expected after the recipe
(unchanged)Imported BOM order controls dependency-management precedence. Sorting these two entries changes which managed version wins, so the recipe changes project behavior rather than presentation alone.
Confirmed real-world execution
pom.xmlata8013f27.martinfrancois/symphony-trello@a8013f27.Anything in particular you'd like reviewers to focus on?
Please review the fixed-position treatment of imported BOMs and the conservative handling of property placeholders. A placeholder in a BOM marker remains fixed because profile-local properties are not always present in the effective model used during the visit.
Have you considered any alternatives or workarounds?
Reapplying the intended BOM order after every recipe run is fragile and makes the recipe non-idempotent for this project.
Any additional context
Pre-existing tests changed: None.
martinfrancois/symphony-trello@a8013f27org.openrewrite:rewrite-maven:8.87.0org.openrewrite:rewrite-maven:8.90.0SortDependenciesTest.doesNotReorderImportedBomsWithSemanticPrecedenceopenrewrite/rewrite@63428228This change was prepared with AI assistance. I reviewed the target execution evidence, implementation, tests, generated metadata, and contribution text.
Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv