Add pom.xml index support to MavenBndRepository - #7137
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add support for Maven pom.xml as index file
Allow MavenBndRepository to use a pom.xml file as its index
Mar 12, 2026
Copilot
AI
changed the title
Allow MavenBndRepository to use a pom.xml file as its index
MavenBndRepository: support pom.xml as index file with full read/write
Mar 12, 2026
Copilot
AI
changed the title
MavenBndRepository: support pom.xml as index file with full read/write
Fix savePom() to write type and classifier elements; use Archive.valueOf overload in readFromPom()
Mar 12, 2026
chrisrueger
force-pushed
the
copilot/allow-mavenbndrepository-use-pom
branch
from
March 12, 2026 19:35
98237f9 to
75d53dc
Compare
chrisrueger
marked this pull request as ready for review
March 12, 2026 19:36
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds pom.xml support for MavenBndRepository index files, enabling automatic detection based on the .xml file extension. It introduces a new POMIndexFile helper class for reading/writing pom.xml format, refactors MbrUpdater to use a new replaceArchive method on IndexFile, and adds secure XML processing to XML.java. The changes ensure that archives with non-jar extensions and classifiers are correctly round-tripped through <type> and <classifier> elements.
Changes:
- New
POMIndexFileutility class for reading Maven pom.xml dependencies and writing them back with proper<type>/<classifier>support, preserving project-level metadata. IndexFilegains anisPomflag (auto-detected from filename), branchingread/savefor pom.xml vs text formats, and a newreplaceArchivemethod for atomic archive replacement.MbrUpdater.update()refactored from manual file I/O to useIndexFile.replaceArchive(), making it format-agnostic.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
POMIndexFile.java |
New helper class with readFromPom and savePom static methods for pom.xml index I/O |
IndexFile.java |
Added isPom flag, pom.xml branching in read/save, new replaceArchive method, renamed save → saveText for text format |
MbrUpdater.java |
Simplified update() to delegate to IndexFile.replaceArchive() instead of manual file manipulation |
XML.java |
Added FEATURE_SECURE_PROCESSING as defense-in-depth for XML parsing |
MavenBndRepoTest.java |
Five new tests for pom.xml index: read, add, remove, replace, metadata preservation, and type/classifier support |
index.pom.xml |
New test resource mirroring index.maven content in pom.xml format |
chrisrueger
force-pushed
the
copilot/allow-mavenbndrepository-use-pom
branch
2 times, most recently
from
March 13, 2026 06:03
e38d349 to
3599943
Compare
Detect of the indexfile is a xml file which is then parsed as a pom.xml file for the index (instead of the flat text file). This could make it easier for to work with tools like dependabot which know pom.xml but not the flat text file of bnd. Note that this pom.xml is very simple and flat and will also be overwritten / recreated when using the "Update Mbr" of the Repobrowser or mbr CLI command (in other words: it can destroy existing maven files. so make sure you are using a dedicated pom.xml file here, which is only used for bnd workspaces) Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> Co-Authored-By: chrisrueger <188422+chrisrueger@users.noreply.github.com>
Enable XMLConstants.FEATURE_SECURE_PROCESSING on the parser to add limits that mitigate XML DoS risks (e.g. entity expansion / resource exhaustion). The call is wrapped in a try/catch that logs an informational message if ParserConfigurationException prevents enabling the feature. This acts as defense-in-depth alongside the existing DOCTYPE and external-entity disabling already performed earlier in the method. Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
chrisrueger
force-pushed
the
copilot/allow-mavenbndrepository-use-pom
branch
from
March 13, 2026 08:08
3599943 to
0caa8c7
Compare
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.
This allows to specify an .xml file which is interpreted as a (flat) pom.xml file for the index (instead of the flat text file). This could make it easier for to work with tools like dependabot which know pom.xml but not the flat text file of bnd.
Note that this pom.xml is very simple (only considers the
<depedency>entries) and flat and will also be overwritten / recreated when using the "Update Mbr" of the Repobrowser or mbr CLI command (in other words: it can destroy existing maven files. so make sure you are using a dedicated pom.xml file here, which is only used for bnd workspaces)The
IndexFileused byMavenBndRepositoryauto-detects if the index is an XML file and if yes, try to parse it as a pom.xml file. So you basically can continue using your existing index file name and just put pom.xml content in it.But note: It should be a very simplistic "pom-like" pom.xml . Not all features are supported. Only the the
<depedency>entries matter.Example
Let's say instead of a
central.mvntext file you want to maintain apom.xml:You can just put that in your
indexin/ext/pom.xmlin your bnd workspace and use it in a repo like below:See https://bnd.bndtools.org/plugins/maven.html
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.