Exclude Eclipse features from P2 Repo .versions()#7296
Open
chrisrueger wants to merge 1 commit into
Open
Conversation
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
fe38c71 to
388b374
Compare
Contributor
Author
|
New approach. Now I filter only in |
chrisrueger
commented
Jun 26, 2026
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; |
Contributor
Author
There was a problem hiding this comment.
@peterkir this is the main change of this PR.
Contributor
There was a problem hiding this comment.
Let's discuss this topic in dev meeting on monday.
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.
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)
@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
-buildpathpicks 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:
versions(String bsn)method inP2Indexernow 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.ECLIPSE_FEATURE_CAPABILITYis introduced to avoid hardcoding the feature type string in multiple places, improving maintainability and reducing errors. [1] [2] [3] [4] [5]API enhancements:
BridgeRepositoryclass adds a newversionInfos(String bsn)method, which returns a map of versions to their associatedResourceInfo, allowing more granular inspection and filtering of resources.Testing improvements:
P2RepositoryTestis updated with new assertions to verify that feature versions are properly filtered out from the main repository, but remain accessible via thegetFeatures()API. This ensures the intended behavior is enforced and tested.Versioning:
aQute.bnd.osgi.repositoryis incremented from 3.3.0 to 3.4.0 to reflect the new API addition.