Skip to content

Exclude Eclipse features from P2 Repo .versions()#7296

Open
chrisrueger wants to merge 1 commit into
bndtools:masterfrom
chrisrueger:7279-fix-attempt2
Open

Exclude Eclipse features from P2 Repo .versions()#7296
chrisrueger wants to merge 1 commit into
bndtools:masterfrom
chrisrueger:7279-fix-attempt2

Conversation

@chrisrueger

@chrisrueger chrisrueger commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Closes #7279
This part 2 of #7292

With this PR the compilation error is gone, because only one version of the real bundle remains (the feature does not appear as a bundle version)

image

@peterkir I am not sure if there are side-effects I have not thought of if we filter out Eclipse Features resources like this. But at least it fixes the compilation probem stated in #7279 (comment) because -buildpath picks the feature bundle (which should not be available at all because it contains no classes)

Summary

This pull request improves how Eclipse features are handled in the P2 repository implementation. The main focus is to ensure that Eclipse features are not returned as bundle versions, preventing them from being incorrectly included in build paths, while still allowing them to be accessed via dedicated feature APIs. It also introduces a new method to retrieve detailed version information and updates tests to verify the correct filtering of features.

Feature filtering and handling:

  • The versions(String bsn) method in P2Indexer now filters out versions corresponding to Eclipse features (org.eclipse.update.feature), so only actual bundle versions are returned. This prevents features from being added to the build path accidentally.
  • A static constant ECLIPSE_FEATURE_CAPABILITY is introduced to avoid hardcoding the feature type string in multiple places, improving maintainability and reducing errors. [1] [2] [3] [4] [5]

API enhancements:

  • The BridgeRepository class adds a new versionInfos(String bsn) method, which returns a map of versions to their associated ResourceInfo, allowing more granular inspection and filtering of resources.

Testing improvements:

  • The P2RepositoryTest is updated with new assertions to verify that feature versions are properly filtered out from the main repository, but remain accessible via the getFeatures() API. This ensures the intended behavior is enforced and tested.

Versioning:

  • The package version for aQute.bnd.osgi.repository is incremented from 3.3.0 to 3.4.0 to reflect the new API addition.

@chrisrueger chrisrueger marked this pull request as ready for review June 26, 2026 19:05
@chrisrueger chrisrueger marked this pull request as draft June 26, 2026 19:32
@chrisrueger

Copy link
Copy Markdown
Contributor Author

Found a problem...

Ensure that p2repo.versions(bsn) does not return versions for features (prevents them from being picked up by -buildpath), and apply this filter when loading resources from an index.

extended test

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>

another approach
@chrisrueger

Copy link
Copy Markdown
Contributor Author

New approach. Now I filter only in P2Repo.versions(bsn)

Comment on lines +186 to +207

// the difficulty for P2Repository is that it als contains features
// but we need to ensure that in versions() we do not return any version
// of a Eclipse Feature
// to avoid that this gets picked up by -buildpath for compilation
Map<Version, ResourceInfo> versionInfos = getBridge().versionInfos(bsn);

TreeSet<Version> versions = new TreeSet<Version>();
Set<Entry<Version, ResourceInfo>> entrySet = versionInfos.entrySet();
for (Entry<Version, ResourceInfo> entry : entrySet) {
Resource resource = entry.getValue()
.getResource();

boolean isFeature = ResourceUtils.hasType(resource, ECLIPSE_FEATURE_CAPABILITY);
if (isFeature) {
continue;
}

versions.add(entry.getKey());
}

return versions;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@peterkir this is the main change of this PR.

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.

Let's discuss this topic in dev meeting on monday.

@chrisrueger chrisrueger marked this pull request as ready for review June 26, 2026 20:47
@chrisrueger chrisrueger requested a review from peterkir June 26, 2026 20:47
@chrisrueger chrisrueger changed the title Exclude Eclipse features from P2Index Bridge Repo Exclude Eclipse features from P2 Repo .versions() Jun 27, 2026
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.

[bndtools 7.3.0] mix up features and bundles in p2 repository

2 participants