I'm having a problem when querying a P2 repo programmatically by category. The P2 repo is online and I have confirmed that is accessible through the normal browser. The P2 repo has the following standard layout:
/features
/plugins
artifacts.xml
category.xml
content.xml
In my code, I would like to query for the available IUs by category. I am trying the following:
// Query the categories.
var query = QueryUtil.createIUCategoryQuery();
var queryResult = repo.query(query, null);
var categories = new HashMap<IInstallableUnit, List<IInstallableUnit>();
for (var category : queryResult) {
categories.add(category, new ArrayList<IInstallableUnit>());
}
// Get the members in each category
for (var category: categories) {
var categoryQuery = QueryUtil.createIUCategoryMemberQuery(category);
var categoryResult = repo.query(categoryQuery, null);
for (var categoryMember: categoryResult) {
categories.get(category).add(categoryMember);
}
}
My category.xml has the following layout:
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature id="myapp.feature.first.feature">
<category name="released" />
</feature>
<feature id="myapp.feature.second.feature">
<category name="in.progress" />
</feature>
<feature id="myapp.feature.third.feature">
<category name="released" />
</feature>
<category-def
name="released"
label="Released" />
<category-def
name="in.progress"
label="In Progress" />
</site>
Problem is, my query for categories doesn't return any results.
On the other hand, if I query directly for installable features using `query = QueryUtil.createIUGroupQuery()` I get all the available features in the repo.
Can you show me what I'm doing wrong either in setting up the category file or in querying for the categories?
Also, if the IUs corresponding to the feature are listed in the content.xml in the format below, I considered that I might be using the wrong feature.id in the category.xml. I also tried, without success, using the following from the content.xml:
- `unit.id` (e.g. `myapp.feature.first.feature.feature.jar`)
- `unit.provides(namespace='org.eclipse.update.feature).name` (e.g. `myapp.feature.first.feature`)
<unit id='myapp.feature.first.feature.feature.jar' version='0.4.0.202108131635'>
<properties size='3'>
<property name='org.eclipse.equinox.p2.name' value='First Feature'/>
<property name='org.eclipse.equinox.p2.description' value=''/>
<property name='org.eclipse.equinox.p2.provider' value=''/>
</properties>
<provides size='3'>
<provided namespace='org.eclipse.equinox.p2.iu' name='myapp.feature.first.feature.feature.jar' version='0.4.0.202108131635'/>
<provided namespace='org.eclipse.equinox.p2.eclipse.type' name='feature' version='1.0.0'/>
<provided namespace='org.eclipse.update.feature' name='myapp.feature.first.feature' version='0.4.0.202108131635'/>
</provides>
<filter>
(org.eclipse.update.install.features=true)
</filter>
<artifacts size='1'>
<artifact classifier='org.eclipse.update.feature' id='myapp.feature.first.feature' version='0.4.0.202108131635'/>
</artifacts>
<touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
<touchpointData size='1'>
<instructions size='1'>
<instruction key='zipped'>
true
</instruction>
</instructions>
</touchpointData>
</unit>
Any help tracing the problem would be appreciated!
[Updated on: Tue, 17 August 2021 15:15] by Moderator