Search in sources :

Example 36 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class ProductDependenciesAction method addPublisherAdvice.

@Override
protected void addPublisherAdvice(IPublisherInfo publisherInfo) {
    // see org.eclipse.equinox.p2.publisher.eclipse.ProductAction.createAdviceFileAdvice()
    File productFileLocation = product.getLocation();
    if (productFileLocation == null) {
        return;
    }
    String id = product.getId();
    Version parseVersion = Version.parseVersion(product.getVersion());
    IPath basePath = new Path(productFileLocation.getParent());
    // must match org.eclipse.tycho.plugins.p2.publisher.PublishProductMojo.getSourceP2InfFile(File)
    final String productFileName = productFileLocation.getName();
    final String p2infFilename = productFileName.substring(0, productFileName.length() - ".product".length()) + ".p2.inf";
    AdviceFileAdvice advice = new AdviceFileAdvice(id, parseVersion, basePath, new Path(p2infFilename));
    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) ProductFile(org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile) File(java.io.File) AdviceFileAdvice(org.eclipse.equinox.p2.publisher.AdviceFileAdvice)

Example 37 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class P2MetadataGeneratorImplTest method gav.

@Test
public void gav() throws Exception {
    P2GeneratorImpl impl = new P2GeneratorImpl(false);
    impl.setBuildPropertiesParser(new BuildPropertiesParserForTesting());
    File location = new File("resources/generator/bundle").getCanonicalFile();
    String groupId = "org.eclipse.tycho.p2.impl.test";
    String artifactId = "bundle";
    String version = "1.0.0-SNAPSHOT";
    List<TargetEnvironment> environments = new ArrayList<>();
    DependencyMetadata metadata = impl.generateMetadata(new ArtifactMock(location, groupId, artifactId, version, PackagingType.TYPE_ECLIPSE_PLUGIN), environments);
    List<IInstallableUnit> units = new ArrayList<>(metadata.getInstallableUnits());
    List<IArtifactDescriptor> artifacts = new ArrayList<>(metadata.getArtifactDescriptors());
    Assert.assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", unit.getId());
    Assert.assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    Assert.assertEquals(2, unit.getRequirements().size());
    Assert.assertEquals(1, artifacts.size());
    IArtifactDescriptor ad = artifacts.iterator().next();
    Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", ad.getArtifactKey().getId());
    Assert.assertEquals("1.0.0.qualifier", ad.getArtifactKey().getVersion().toString());
    Assert.assertEquals(groupId, ad.getProperties().get(RepositoryLayoutHelper.PROP_GROUP_ID));
    Assert.assertEquals(artifactId, ad.getProperties().get(RepositoryLayoutHelper.PROP_ARTIFACT_ID));
    Assert.assertEquals(version, ad.getProperties().get(RepositoryLayoutHelper.PROP_VERSION));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ArrayList(java.util.ArrayList) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) P2GeneratorImpl(org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl) BuildPropertiesParserForTesting(org.eclipse.tycho.test.util.BuildPropertiesParserForTesting) DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) Test(org.junit.Test)

Example 38 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class CompositeArtifactProviderTestBase method testContainsKey.

@Test
public void testContainsKey() {
    assertTrue(subject.contains(BUNDLE_A_KEY));
    assertTrue(subject.contains(BUNDLE_B_KEY));
    String otherClassifier = "org.eclipse.update.feature";
    Version otherVersion = Version.emptyVersion;
    assertFalse(subject.contains(new ArtifactKey(otherClassifier, BUNDLE_A_KEY.getId(), BUNDLE_A_KEY.getVersion())));
    assertFalse(subject.contains(new ArtifactKey(BUNDLE_A_KEY.getClassifier(), BUNDLE_A_KEY.getId(), otherVersion)));
}
Also used : IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) ArtifactKey(org.eclipse.equinox.internal.p2.metadata.ArtifactKey) Version(org.eclipse.equinox.p2.metadata.Version) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 39 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class LocalMetadataRepositoryTest method addInstallableUnit.

@Test
public void addInstallableUnit() throws CoreException {
    File location = new File("target/metadataRepo");
    LocalMetadataRepository repository = createRepository(location);
    InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
    iud.setId("test");
    iud.setVersion(Version.parseVersion("1.0.0"));
    iud.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
    iud.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, "artifact");
    iud.setProperty(RepositoryLayoutHelper.PROP_VERSION, "version");
    InstallableUnitDescription iud2 = new MetadataFactory.InstallableUnitDescription();
    iud2.setId("test2");
    iud2.setVersion(Version.parseVersion("1.0.0"));
    iud2.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
    iud2.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, "artifact2");
    iud2.setProperty(RepositoryLayoutHelper.PROP_VERSION, "version");
    IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
    IInstallableUnit iu2 = MetadataFactory.createInstallableUnit(iud2);
    repository.addInstallableUnits(Arrays.asList(iu, iu2));
    repository = (LocalMetadataRepository) loadRepository(location);
    IQueryResult<IInstallableUnit> result = repository.query(QueryUtil.ALL_UNITS, monitor);
    ArrayList<IInstallableUnit> allius = new ArrayList<>(result.toSet());
    Assert.assertEquals(2, allius.size());
    // as of e3.5.2 Collector uses HashSet internally and does not guarantee collected results order
    // 3.6 IQueryResult, too, is backed by HashSet. makes no sense.
    // Assert.assertEquals( iu.getId(), allius.get( 0 ).getId() );
    Set<IInstallableUnit> ius = repository.getGAVs().get(RepositoryLayoutHelper.getGAV(iu.getProperties()));
    Assert.assertEquals(1, ius.size());
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) Test(org.junit.Test)

Example 40 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class BaselineServiceImpl method getBaselineUnit.

private IInstallableUnit getBaselineUnit(IQueryable<IInstallableUnit> units, String id, Version version) {
    IQueryResult<IInstallableUnit> result = units.query(QueryUtil.createIUQuery(id, version), monitor);
    if (result.isEmpty()) {
        return null;
    }
    Iterator<IInstallableUnit> iterator = result.iterator();
    IInstallableUnit unit = iterator.next();
    if (iterator.hasNext()) {
        throw new IllegalArgumentException();
    }
    return unit;
}
Also used : IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

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