Search in sources :

Example 31 with Version

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);
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 32 with Version

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));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 33 with Version

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));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 34 with Version

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"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Attributes(java.util.jar.Attributes) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ITouchpointData(org.eclipse.equinox.p2.metadata.ITouchpointData) Manifest(java.util.jar.Manifest) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Example 35 with Version

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);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Version(org.eclipse.equinox.p2.metadata.Version) AdviceFileAdvice(org.eclipse.equinox.p2.publisher.AdviceFileAdvice)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)25 Version (org.eclipse.equinox.p2.metadata.Version)15 Test (org.junit.Test)15 File (java.io.File)12 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)12 ArrayList (java.util.ArrayList)8 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)7 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)7 IStatus (org.eclipse.core.runtime.IStatus)5 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)5 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)5 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CoreException (org.eclipse.core.runtime.CoreException)3 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)3 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2