Search in sources :

Example 26 with IArtifactDescriptor

use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.

the class P2GeneratorImpl method persistMetadata.

@Override
public void persistMetadata(Map<String, IP2Artifact> metadata, File unitsXml, File artifactsXml) throws IOException {
    Set<IInstallableUnit> units = new LinkedHashSet<>();
    Set<IArtifactDescriptor> artifactDescriptors = new LinkedHashSet<>();
    for (IP2Artifact artifact : metadata.values()) {
        for (Object unit : artifact.getInstallableUnits()) {
            units.add((IInstallableUnit) unit);
        }
        artifactDescriptors.add((IArtifactDescriptor) artifact.getArtifactDescriptor());
    }
    new MetadataIO().writeXML(units, unitsXml);
    new ArtifactsIO().writeXML(artifactDescriptors, artifactsXml);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) ArtifactsIO(org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 27 with IArtifactDescriptor

use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.

the class FeatureRootfileArtifactRepositoryTest method testRepoForNonBinaryArtifacts.

@Test
public void testRepoForNonBinaryArtifacts() throws Exception {
    FeatureRootfileArtifactRepository subject = new FeatureRootfileArtifactRepository(createPublisherInfo(true), tempFolder.newFolder("testrootfiles"));
    IArtifactDescriptor artifactDescriptor = createArtifactDescriptor("non-binary-classifier", "org.eclipse.tycho.test.p2");
    subject.getOutputStream(artifactDescriptor).close();
    Map<String, IP2Artifact> attachedArtifacts = subject.getPublishedArtifacts();
    Assert.assertEquals(0, attachedArtifacts.size());
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) FeatureRootAdviceTest(org.eclipse.tycho.p2.impl.publisher.rootfiles.FeatureRootAdviceTest) Test(org.junit.Test)

Example 28 with IArtifactDescriptor

use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor 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 29 with IArtifactDescriptor

use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.

the class ModuleArtifactRepositoryTest method artifactSizeOf.

private static int artifactSizeOf(IArtifactKey artifactKey, IArtifactRepository subject) {
    IArtifactDescriptor[] artifactDescriptors = subject.getArtifactDescriptors(artifactKey);
    assertEquals(1, artifactDescriptors.length);
    ByteArrayOutputStream artifactContent = new ByteArrayOutputStream();
    subject.getArtifact(artifactDescriptors[0], artifactContent, null);
    return artifactContent.size();
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 30 with IArtifactDescriptor

use of org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor in project tycho by eclipse.

the class PublishingRepositoryTest method testArtifactDescriptor.

@Test
public void testArtifactDescriptor() throws Exception {
    // simulate that AttachedTestArtifact is the build output
    insertTestArtifact(subject);
    IArtifactRepository artifactRepo = subject.getArtifactRepository();
    assertThat(allKeysIn(artifactRepo), hasItem(AttachedTestArtifact.key));
    IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(AttachedTestArtifact.key);
    assertThat(descriptors.length, is(1));
    Map<String, String> props = descriptors[0].getProperties();
    assertThat(props.get(RepositoryLayoutHelper.PROP_GROUP_ID), is(project.getGroupId()));
    assertThat(props.get(RepositoryLayoutHelper.PROP_ARTIFACT_ID), is(project.getArtifactId()));
    assertThat(props.get(RepositoryLayoutHelper.PROP_VERSION), is(project.getVersion()));
    assertThat(props.get(RepositoryLayoutHelper.PROP_CLASSIFIER), is(AttachedTestArtifact.classifier));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Aggregations

IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)32 Test (org.junit.Test)16 File (java.io.File)9 IStatus (org.eclipse.core.runtime.IStatus)8 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)7 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)6 OutputStream (java.io.OutputStream)5 ArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor)5 IOException (java.io.IOException)4 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)4 FeatureRootAdviceTest (org.eclipse.tycho.p2.impl.publisher.rootfiles.FeatureRootAdviceTest)4 ArtifactsIO (org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO)4 IP2Artifact (org.eclipse.tycho.p2.metadata.IP2Artifact)4 BufferedOutputStream (java.io.BufferedOutputStream)3 FileOutputStream (java.io.FileOutputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileInputStream (java.io.FileInputStream)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2