use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class TargetPlatformFactoryImpl method getPreliminaryReactorProjectUIs.
private Map<IInstallableUnit, ReactorProjectIdentities> getPreliminaryReactorProjectUIs(List<ReactorProject> reactorProjects) throws DuplicateReactorIUsException {
if (reactorProjects == null) {
return Collections.emptyMap();
}
Map<IInstallableUnit, ReactorProjectIdentities> reactorUIs = new HashMap<>();
Map<IInstallableUnit, Set<File>> duplicateReactorUIs = new HashMap<>();
for (ReactorProject project : reactorProjects) {
@SuppressWarnings("unchecked") Set<IInstallableUnit> projectIUs = (Set<IInstallableUnit>) project.getDependencyMetadata();
if (projectIUs == null)
continue;
for (IInstallableUnit iu : projectIUs) {
ReactorProjectIdentities otherOrigin = reactorUIs.put(iu, project.getIdentities());
if (otherOrigin != null && !otherOrigin.equals(project.getIdentities())) {
Set<File> duplicateLocations = duplicateReactorUIs.get(iu);
if (duplicateLocations == null) {
duplicateLocations = new LinkedHashSet<>();
duplicateReactorUIs.put(iu, duplicateLocations);
}
duplicateLocations.add(otherOrigin.getBasedir());
duplicateLocations.add(project.getBasedir());
}
}
}
if (!duplicateReactorUIs.isEmpty()) {
// TODO 392320 we should only fail if IUs with same id and version but different content are found
throw new DuplicateReactorIUsException(duplicateReactorUIs);
}
return reactorUIs;
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class CustomEEResolutionHandler method readCapabilities.
private List<SystemCapability> readCapabilities(IInstallableUnit specificationUnit) {
List<SystemCapability> result = new ArrayList<>();
for (IProvidedCapability capability : specificationUnit.getProvidedCapabilities()) {
String namespace = capability.getNamespace();
String name = capability.getName();
String version = capability.getVersion().toString();
if (JREAction.NAMESPACE_OSGI_EE.equals(namespace)) {
result.add(new SystemCapability(Type.OSGI_EE, name, version));
} else if (PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(namespace)) {
result.add(new SystemCapability(Type.JAVA_PACKAGE, name, version));
} else {
// ignore
}
}
return result;
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class BundleDependenciesAction method createAdviceFileAdvice.
@Override
protected void createAdviceFileAdvice(BundleDescription bundleDescription, IPublisherInfo publisherInfo) {
String location = bundleDescription.getLocation();
if (location == null)
return;
File adviceFile = new File(location, AdviceFileAdvice.BUNDLE_ADVICE_FILE.toString());
if (!adviceFile.canRead()) {
return;
}
Map<String, String> advice = new LinkedHashMap<>();
try {
InputStream is = new BufferedInputStream(new FileInputStream(adviceFile));
try {
Properties props = new Properties();
props.load(is);
for (Map.Entry<Object, Object> p : props.entrySet()) {
advice.put((String) p.getKey(), (String) p.getValue());
}
} finally {
try {
is.close();
} catch (IOException secondary) {
// secondary exception
}
}
} catch (IOException e) {
// TODO log
return;
}
final String symbolicName = bundleDescription.getSymbolicName();
final Version bundleVersion = PublisherHelper.fromOSGiVersion(bundleDescription.getVersion());
AdviceFileParser parser = new AdviceFileParser(symbolicName, bundleVersion, advice) {
@Override
protected IRequirement createRequirement(String namespace, String name, VersionRange range, String filter, boolean optional, boolean multiple, boolean greedy) {
if (optionalAction == OptionalResolutionAction.OPTIONAL) {
return super.createRequirement(namespace, name, range, filter, optional, multiple, greedy);
}
return BundleDependenciesAction.this.createRequirement(namespace, name, range, filter, optional, multiple, greedy);
}
};
try {
parser.parse();
} catch (Exception e) {
// TODO log
return;
}
final IProvidedCapability[] provided = parser.getProvidedCapabilities();
final IRequirement[] required = parser.getRequiredCapabilities();
if (provided == null && required == null) {
return;
}
publisherInfo.addAdvice(new ICapabilityAdvice() {
@Override
public boolean isApplicable(String configSpec, boolean includeDefault, String id, Version version) {
return symbolicName.equals(id) && bundleVersion.equals(version);
}
@Override
public IRequirement[] getRequiredCapabilities(InstallableUnitDescription iu) {
return required;
}
@Override
public IProvidedCapability[] getProvidedCapabilities(InstallableUnitDescription iu) {
return provided;
}
@Override
public IRequirement[] getMetaRequiredCapabilities(InstallableUnitDescription iu) {
return null;
}
});
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class FeatureDependenciesAction method getVersionRange.
/**
* Copy&Paste from 3.7
* org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction.getVersionRange(FeatureEntry)
*/
private VersionRange getVersionRange(FeatureEntry entry) {
String versionSpec = entry.getVersion();
if (versionSpec == null)
return VersionRange.emptyRange;
String match = entry.getMatch();
if (// $NON-NLS-1$
"versionRange".equals(match))
return new VersionRange(versionSpec);
Version version = Version.parseVersion(versionSpec);
if (version.equals(Version.emptyVersion))
return VersionRange.emptyRange;
if (!entry.isRequires())
return new VersionRange(version, true, version, true);
if (match == null)
// TODO should really be returning VersionRange.emptyRange here...
return null;
if (// $NON-NLS-1$
match.equals("perfect"))
return new VersionRange(version, true, version, true);
org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(version);
if (match.equals("equivalent")) {
// $NON-NLS-1$
Version upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor() + 1, 0);
return new VersionRange(version, true, upper, false);
}
if (match.equals("compatible")) {
// $NON-NLS-1$
Version upper = Version.createOSGi(osgiVersion.getMajor() + 1, 0, 0);
return new VersionRange(version, true, upper, false);
}
if (// $NON-NLS-1$
match.equals("greaterOrEqual"))
return new VersionRange(version, true, new VersionRange(null).getMaximum(), true);
return null;
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class ProductDependenciesAction method getRequiredCapabilities.
@Override
protected Set<IRequirement> getRequiredCapabilities() {
Set<IRequirement> required = new LinkedHashSet<>();
if (product.useFeatures()) {
for (IVersionedId feature : product.getFeatures()) {
// $NON-NLS-1$
String id = feature.getId() + FEATURE_GROUP_IU_SUFFIX;
Version version = feature.getVersion();
addRequiredCapability(required, id, version, null, false);
}
} else {
for (FeatureEntry plugin : ((ProductFile) product).getProductEntries()) {
addRequiredCapability(required, plugin.getId(), Version.parseVersion(plugin.getVersion()), null, true);
}
}
if (product.includeLaunchers()) {
addRequiredCapability(required, "org.eclipse.equinox.executable.feature.group", null, null, false);
}
return required;
}
Aggregations