use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class P2ResolverAdditionalRequirementsTest method testExactVersionMatchInTargetDefinitionUnit.
@Test
public void testExactVersionMatchInTargetDefinitionUnit() throws Exception {
String olderVersion = "2.3.3";
String version = "2.3.4";
String newerVersion = "2.3.5";
String exactVersionMatchRange = "[" + version + "," + version + "]";
impl.addDependency(IU_TYPE, TARGET_UNIT_ID, exactVersionMatchRange);
impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, exactVersionMatchRange);
List<IRequirement> requirements = impl.getAdditionalRequirements();
IInstallableUnit matchingIU = createIU(version);
assertIUMatchesRequirements(matchingIU, requirements);
IInstallableUnit newerIU = createIU(newerVersion);
assertIUDoesNotMatchRequirements(newerIU, requirements);
IInstallableUnit olderIU = createIU(olderVersion);
assertIUDoesNotMatchRequirements(olderIU, requirements);
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class P2ResolverAdditionalRequirementsTest method testAddDependencyWithVersionRange.
@Test
public void testAddDependencyWithVersionRange() throws Exception {
String range = "[2.0.0,3.0.0)";
impl.addDependency(IU_TYPE, TARGET_UNIT_ID, range);
impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, range);
List<IRequirement> additionalRequirements = impl.getAdditionalRequirements();
String matchingVersion = "2.5.8";
IInstallableUnit iu = createIU(matchingVersion);
Assert.assertTrue("version range " + range + " should be satisfied by " + matchingVersion, additionalRequirements.get(0).isMatch(iu));
Assert.assertTrue("version range " + range + " should be satisfied by " + matchingVersion, additionalRequirements.get(1).isMatch(iu));
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class P2ResolverAdditionalRequirementsTest method testZeroVersionInTargetDefinitionUnit.
@Test
public void testZeroVersionInTargetDefinitionUnit() throws Exception {
String zeroVersion = "0.0.0";
String arbitraryVersion = "2.5.8";
impl.addDependency(IU_TYPE, TARGET_UNIT_ID, zeroVersion);
impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, zeroVersion);
List<IRequirement> additionalRequirements = impl.getAdditionalRequirements();
IInstallableUnit iu = createIU(arbitraryVersion);
Assert.assertTrue("Requires version 0.0.0; should be satisfied by any version", additionalRequirements.get(0).isMatch(iu));
Assert.assertTrue("Requires version 0.0.0; should be satisfied by any version", additionalRequirements.get(1).isMatch(iu));
}
use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.
the class P2GeneratorImplTest method testGenerateSourceBundleMetadata.
@Test
public void testGenerateSourceBundleMetadata() throws Exception {
DependencyMetadataGenerator p2GeneratorImpl = new SourcesBundleDependencyMetadataGenerator();
File location = new File("resources/generator/bundle").getCanonicalFile();
ArtifactMock artifactMock = new ArtifactMock(location, "org.acme", "foo", "0.0.1", "eclipse-plugin");
Set<Object> units = p2GeneratorImpl.generateMetadata(artifactMock, getEnvironments(), null).getMetadata();
assertEquals(1, units.size());
IInstallableUnit sourceBundleUnit = getUnit("foo.source", units);
assertNotNull(sourceBundleUnit);
assertEquals(Version.create("0.0.1"), sourceBundleUnit.getVersion());
assertThat(sourceBundleUnit, hasGAV("org.acme", "foo", "0.0.1", "sources"));
ITouchpointData touchPointData = sourceBundleUnit.getTouchpointData().iterator().next();
String manifestContent = touchPointData.getInstruction("manifest").getBody();
Manifest manifest = new Manifest(new ByteArrayInputStream(manifestContent.getBytes("UTF-8")));
Attributes attributes = manifest.getMainAttributes();
assertEquals("foo.source", attributes.getValue("Bundle-SymbolicName"));
// assertEquals("foo;version=0.0.1;roots:=\".\"", attributes.getValue("Eclipse-SourceBundle"));
}
use of org.eclipse.equinox.p2.metadata.Version 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);
}
}
Aggregations