[LM-467] fix(maven): merge Endor server/mirror into existing settings… - #17
Open
Mahesh-Kete wants to merge 2 commits into
Open
[LM-467] fix(maven): merge Endor server/mirror into existing settings…#17Mahesh-Kete wants to merge 2 commits into
Mahesh-Kete wants to merge 2 commits into
Conversation
….xml containers instead of appending duplicate <servers>/<mirrors> for bash file
…e guard, empty/malformed settings.xml handling, non-destructive XML removal, chown newly created config dirs to console user
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.
LM-467 Merge-aware Maven settings.xml + config-writer hardening (bash)
What this PR does
1. Merge-aware
settings.xmlwriter (c55ab09) — the original LM-467 change. Maven's schema forbids duplicate<servers>/<mirrors>containers, so the Endor<server>/<mirror>entries are now wrapped in per-entry sentinel markers and merged into whichever containers already exist (inserted as first child so the Endor catch-all mirror wins precedence); containers are created in schema order only when absent. Legacy combined-block files from older script versions are still recognized and migrated on re-run/removal.2. Four bug fixes in
lib/common.sh(58b5c16) — found during a full scan of the shared runtime library:upsert_blockglued the BEGIN sentinel onto the file's last line; the substring-based strip on re-run/removal then silently deleted that user line (or the whole file).settings.xml. A file that existed but was empty (or had no</settings>) gave the insert logic no anchor line — the Endor entries were silently dropped while the script reported success, leaving the Maven firewall unenforced with a false green in the MDM console.</settings>→ loud stderr ERROR + rc 1, which aborts theset -euo pipefailscript so the MDM console shows a real failure. DRY_RUN reports CREATE/FAIL accordingly.settings.xmlthat still held user settings. The "anything real left?" whitelist regex missed legitimate elements like<offline>/<interactiveMode>, so a file containing only those wasrm -f'd on uninstall.mkdir -pleft newly created dirs (worst:~/.m2, potentially~/.config) ownedroot:wheel755. The user could read but not write inside — so Maven later failed to create~/.m2/repository("Could not create local repository") and every build died, weeks after a green install._endor_mkdir_ownedhelper: records the topmost path segment that didn't exist,mkdir -ps, thenchown -Rs only that newly created segment to the console user. Pre-existing directories are provably never touched; no-op when the chain already exists.Design decisions
settings.xml: an emptied<servers></servers>/<mirrors></mirrors>skeleton left behind is valid, no-op XML — a fair price for never risking user config.Testing
Verified with a 41-assertion harness exercising the library directly: fresh create, re-run idempotency, merge into existing/self-closed/single-line containers, Endor-mirror-first precedence, legacy block migration, empty & malformed settings.xml, install→remove→reinstall round-trip, newline-less flat files, and directory-ownership behavior (via chown-call interception: recursive chown lands on exactly the topmost newly created segment; never on pre-existing dirs).
Follow-ups (not in this PR)
bash/out/embeds this library at generation time — regenerate viagenerate.shso deployed scripts pick up the fixes.