use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project tycho by eclipse.
the class FeatureDependenciesAction method addPublisherAdvice.
@Override
protected void addPublisherAdvice(IPublisherInfo publisherInfo) {
// see org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction.createAdviceFileAdvice(Feature, IPublisherInfo)
IPath location = new Path(feature.getLocation());
Version version = Version.parseVersion(feature.getVersion());
String groupId = getId();
AdviceFileAdvice advice = new AdviceFileAdvice(groupId, version, location, new Path("p2.inf"));
if (advice.containsAdvice()) {
publisherInfo.addAdvice(advice);
}
}
use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project tycho by eclipse.
the class P2GeneratorImpl method getPublisherActions.
@Override
protected List<IPublisherAction> getPublisherActions(IArtifactFacade artifact, List<TargetEnvironment> environments, OptionalResolutionAction optionalAction) {
if (!dependenciesOnly && optionalAction != null) {
throw new IllegalArgumentException();
}
List<IPublisherAction> actions = new ArrayList<>();
String packaging = artifact.getPackagingType();
File location = artifact.getLocation();
if (PackagingType.TYPE_ECLIPSE_PLUGIN.equals(packaging) || PackagingType.TYPE_ECLIPSE_TEST_PLUGIN.equals(packaging)) {
if (dependenciesOnly && optionalAction != null) {
actions.add(new BundleDependenciesAction(location, optionalAction));
} else {
actions.add(new BundlesAction(new File[] { location }));
}
} else if (PackagingType.TYPE_ECLIPSE_FEATURE.equals(packaging)) {
Feature feature = new FeatureParser().parse(location);
feature.setLocation(location.getAbsolutePath());
if (dependenciesOnly) {
actions.add(new FeatureDependenciesAction(feature));
} else {
actions.add(new FeaturesAction(new Feature[] { feature }));
}
} else if (PackagingType.TYPE_ECLIPSE_APPLICATION.equals(packaging)) {
String product = new File(location, artifact.getArtifactId() + ".product").getAbsolutePath();
try {
IProductDescriptor productDescriptor = new ProductFile2(product);
if (dependenciesOnly) {
actions.add(new ProductDependenciesAction(productDescriptor));
} else {
actions.add(new ProductAction(product, productDescriptor, null, null));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (PackagingType.TYPE_ECLIPSE_UPDATE_SITE.equals(packaging)) {
if (dependenciesOnly) {
actions.add(new SiteDependenciesAction(location, artifact.getArtifactId(), artifact.getVersion()));
} else {
actions.add(new SiteXMLAction(location.toURI(), null));
}
} else if (PackagingType.TYPE_ECLIPSE_REPOSITORY.equals(packaging)) {
for (File productFile : getProductFiles(location)) {
String product = productFile.getAbsolutePath();
IProductDescriptor productDescriptor;
try {
productDescriptor = new ProductFile2(product);
} catch (Exception e) {
throw new RuntimeException("Unable to parse the product file " + product, e);
}
if (dependenciesOnly) {
actions.add(new ProductDependenciesAction(productDescriptor));
}
}
for (File categoryFile : getCategoryFiles(location)) {
CategoryParser cp = new CategoryParser(null);
FileInputStream ins = null;
try {
try {
ins = new FileInputStream(categoryFile);
SiteModel siteModel = cp.parse(ins);
actions.add(new CategoryDependenciesAction(siteModel, artifact.getArtifactId(), artifact.getVersion()));
} finally {
if (ins != null) {
ins.close();
}
}
} catch (Exception e) {
throw new RuntimeException("Unable to read category File", e);
}
}
} else if (PackagingType.TYPE_P2_IU.equals(packaging)) {
actions.add(new AuthoredIUAction(location));
} else if (location.isFile() && location.getName().endsWith(".jar")) {
actions.add(new BundlesAction(new File[] { location }));
} else {
throw new IllegalArgumentException("Unknown type of packaging " + packaging);
}
return actions;
}
use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project tycho by eclipse.
the class P2DependencyGeneratorImplTest method feature_with_p2_inf.
@Test
public void feature_with_p2_inf() throws Exception {
generateDependencies("feature-p2-inf", PackagingType.TYPE_ECLIPSE_FEATURE);
List<IInstallableUnit> units = new ArrayList<>(this.units);
// no feature.jar IU because dependencyOnly=true
assertEquals(2, units.size());
// TODO
IInstallableUnit unit = units.get(0);
assertEquals("org.eclipse.tycho.p2.impl.test.feature-p2-inf.feature.group", unit.getId());
assertEquals("1.0.0.qualifier", unit.getVersion().toString());
List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
assertEquals(1, requirements.size());
IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
assertEquals(IInstallableUnit.NAMESPACE_IU_ID, requirement.getNamespace());
assertEquals("required.p2.inf", requirement.getName());
assertEquals(0, artifacts.size());
assertEquals("iu.p2.inf", units.get(1).getId());
}
use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project tycho by eclipse.
the class P2DependencyGeneratorImplTest method feature.
@Test
public void feature() throws Exception {
generateDependencies("feature", PackagingType.TYPE_ECLIPSE_FEATURE);
// no feature.jar IU because dependencyOnly=true
assertEquals(1, units.size());
IInstallableUnit unit = units.iterator().next();
assertEquals("org.eclipse.tycho.p2.impl.test.feature.feature.group", unit.getId());
assertEquals("1.0.0.qualifier", unit.getVersion().toString());
assertEquals(DEFAULT_CLASSIFIER, unit.getProperty(RepositoryLayoutHelper.PROP_CLASSIFIER));
List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
assertEquals(6, requirements.size());
IRequiredCapability capability = getRequiredCapability("another.required.feature.feature.group", requirements);
IMatchExpression<IInstallableUnit> matches = capability.getMatches();
assertEquals("providedCapabilities.exists(x | x.name == $0 && x.namespace == $1 && x.version >= $2 && x.version < $3)", matches.toString());
assertEquals(Version.parseVersion("1.0.0"), matches.getParameters()[2]);
assertEquals(Version.parseVersion("2.0.0"), matches.getParameters()[3]);
assertEquals(0, artifacts.size());
}
use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project gemoc-studio by eclipse.
the class PrepareInstallProfileJob method queryInstallableUnits.
/**
* Perform a query to get the installable units. This causes p2 to determine
* what features are available in each repository. We select installable
* units by matching both the feature id and the repository; it is possible
* though unlikely that the same feature id is available from more than one
* of the selected repositories, and we must ensure that the user gets the
* one that they asked for.
*/
private List<IInstallableUnit> queryInstallableUnits(SubMonitor monitor, List<IMetadataRepository> repositories) throws URISyntaxException {
final List<IInstallableUnit> installableUnits = new ArrayList<IInstallableUnit>();
monitor.setWorkRemaining(repositories.size());
for (final IMetadataRepository repository : repositories) {
checkCancelled(monitor);
final Set<String> installableUnitIdsThisRepository = getDescriptorIds(repository);
IQuery<IInstallableUnit> query = //
QueryUtil.createMatchQuery(// $NON-NLS-1$
"id ~= /*.feature.group/ && " + // $NON-NLS-1$
"properties['org.eclipse.equinox.p2.type.group'] == true ");
IQueryResult<IInstallableUnit> result = repository.query(query, monitor.newChild(1));
for (Iterator<IInstallableUnit> iter = result.iterator(); iter.hasNext(); ) {
IInstallableUnit iu = iter.next();
String id = iu.getId();
if (installableUnitIdsThisRepository.contains(id.substring(0, id.indexOf(P2_FEATURE_GROUP_SUFFIX)))) {
installableUnits.add(iu);
}
}
}
return installableUnits;
}
Aggregations