Fix #400 - Preserve POM content ordering (and formatting) on resolveCiFriendliesOnly flattenMode #446
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.
As reported in #400,
resolveCiFriendliesOnlyflattenMode doesn't preserve POM content ordering, formatting or comments (KeepCommentsInPomis just a less-than-ideal workaround which quickly falls apart when comment nodes relate to sections rather than single elements); this is typically inconvenient, as users who don't apply other transformations may legitimately expect the output being identical to the input, interpolation aside.This fix provides such functionality, interpolating the original POM without interfering with its formatting, ordering or comments. Leveraging the simple placeholder syntax (which doesn't require deserialization for modifications), the original POM content string is processed for interpolation as a whole.
En passant, this PR possibly fixes also #401 as, debugging the main fix,
CiInterpolatorImpl.interpolate(...)initially behaved weirdly, assigning a spurious value to unresolved placeholders (any expression other than CI-friendly properties was resolved to its name (eg,"${test.version}"->"test.version")?!):With this fix, any unknown placeholder is duly left unresolved:
Additionally,
toString()method ofPomPropertyandCacheFieldhas been overridden to improve debugging intelligibility.Testing
KeepCommentsInPomTestresources have been updated to pass the new implementation