Skip to content

Add pom.xml index support to MavenBndRepository - #7137

Merged
chrisrueger merged 2 commits into
masterfrom
copilot/allow-mavenbndrepository-use-pom
Mar 13, 2026
Merged

Add pom.xml index support to MavenBndRepository#7137
chrisrueger merged 2 commits into
masterfrom
copilot/allow-mavenbndrepository-use-pom

Conversation

Copilot AI commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

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 IndexFile used by MavenBndRepository auto-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.mvn text file you want to maintain a pom.xml:

image

You can just put that in your index in /ext/pom.xml in your bnd workspace and use it in a repo like below:

-plugin.Testing: \
    aQute.bnd.repository.maven.provider.MavenBndRepository; \
        snapshotUrl=http://repository.apache.org/snapshots/; \
        releaseUrl=https://repo.maven.apache.org/maven2/; \
        index=./ext/pom.xml; \
        readOnly=true; \
        name="Testing Bundles"

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.

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
chrisrueger force-pushed the copilot/allow-mavenbndrepository-use-pom branch from 98237f9 to 75d53dc Compare March 12, 2026 19:35
@chrisrueger
chrisrueger requested a review from Copilot March 12, 2026 19:36
@chrisrueger
chrisrueger marked this pull request as ready for review March 12, 2026 19:36
@chrisrueger chrisrueger changed the title Fix savePom() to write type and classifier elements; use Archive.valueOf overload in readFromPom() Add pom.xml index support to MavenBndRepository Mar 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 POMIndexFile utility class for reading Maven pom.xml dependencies and writing them back with proper <type>/<classifier> support, preserving project-level metadata.
  • IndexFile gains an isPom flag (auto-detected from filename), branching read/save for pom.xml vs text formats, and a new replaceArchive method for atomic archive replacement.
  • MbrUpdater.update() refactored from manual file I/O to use IndexFile.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 savesaveText 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
chrisrueger force-pushed the copilot/allow-mavenbndrepository-use-pom branch 2 times, most recently from e38d349 to 3599943 Compare March 13, 2026 06:03
Copilot AI and others added 2 commits March 13, 2026 09:08
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
chrisrueger force-pushed the copilot/allow-mavenbndrepository-use-pom branch from 3599943 to 0caa8c7 Compare March 13, 2026 08:08
@chrisrueger
chrisrueger merged commit ff892c7 into master Mar 13, 2026
20 checks passed
@chrisrueger
chrisrueger deleted the copilot/allow-mavenbndrepository-use-pom branch March 13, 2026 11:03
chrisrueger added a commit that referenced this pull request Mar 14, 2026
Clarify the index file format and its usage in the documentation.
related to #7137 and #7138

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants