Search in sources :

Example 16 with IArtifactDescriptor

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

the class ArtifactTransferPolicyBase method sortFormatsByPreference.

@Override
public final List<IArtifactDescriptor> sortFormatsByPreference(IArtifactDescriptor[] artifactDescriptors) {
    LinkedList<IArtifactDescriptor> result = new LinkedList<>();
    IArtifactDescriptor canonical = null;
    IArtifactDescriptor packed = null;
    for (IArtifactDescriptor descriptor : artifactDescriptors) {
        if (isCanonicalFormat(descriptor)) {
            canonical = descriptor;
        } else if (isPack200Format(descriptor)) {
            packed = descriptor;
        } else {
            result.add(descriptor);
        }
    }
    insertCanonicalAndPacked(canonical, packed, result);
    return result;
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) LinkedList(java.util.LinkedList)

Example 17 with IArtifactDescriptor

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

the class VerifierServiceImpl method verifyAllArtifactContent.

private boolean verifyAllArtifactContent(IArtifactRepository repository, MavenLogger logger) {
    boolean valid = true;
    IQueryResult<IArtifactKey> allKeys = repository.query(new ExpressionMatchQuery<>(IArtifactKey.class, ExpressionUtil.TRUE_EXPRESSION), null);
    for (Iterator<IArtifactKey> keyIt = allKeys.iterator(); keyIt.hasNext(); ) {
        IArtifactKey key = keyIt.next();
        IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key);
        for (IArtifactDescriptor descriptor : descriptors) {
            valid &= verifyArtifactContent(repository, logger, descriptor);
        }
    }
    return valid;
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey)

Example 18 with IArtifactDescriptor

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

the class ArtifactRepositoryTestUtils method packedDescriptorFor.

public static IArtifactDescriptor packedDescriptorFor(IArtifactKey key) {
    ArtifactDescriptor result = new ArtifactDescriptor(key);
    result.setProcessingSteps(new IProcessingStepDescriptor[] { new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true) });
    result.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED);
    return result;
}
Also used : ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IProcessingStepDescriptor(org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor) ProcessingStepDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor)

Example 19 with IArtifactDescriptor

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

the class ModuleArtifactRepositoryTest method testReadingWithOtherDescriptorType.

@Test
public void testReadingWithOtherDescriptorType() throws Exception {
    subject = ModuleArtifactRepository.restoreInstance(null, existingModuleDir);
    IArtifactDescriptor originalDescriptor = subject.getArtifactDescriptors(BUNDLE_ARTIFACT_KEY)[0];
    IArtifactDescriptor equivalentDescriptor = new ArtifactDescriptor(originalDescriptor);
    assertThat(subject.contains(BUNDLE_ARTIFACT_KEY), is(true));
    assertThat(subject.contains(originalDescriptor), is(true));
    assertThat(subject.contains(equivalentDescriptor), is(true));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) Test(org.junit.Test)

Example 20 with IArtifactDescriptor

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

the class ModuleArtifactRepositoryTest method testRemovingWithOtherDescriptorType.

@Test
public void testRemovingWithOtherDescriptorType() throws Exception {
    // existingModuleDir points to the original source files -> use temporary repository instead so that we don't edit source files
    subject = ModuleArtifactRepository.createInstance(null, tempManager.newFolder("targetDir"));
    // TODO write via sink
    OutputStream outputStream = subject.getOutputStream(newDescriptor(BINARY_ARTIFACT_KEY));
    writeAndClose(outputStream, BINARY_ARTIFACT_SIZE);
    IArtifactDescriptor originalDescriptor = subject.getArtifactDescriptors(BINARY_ARTIFACT_KEY)[0];
    IArtifactDescriptor equivalentDescriptor = new ArtifactDescriptor(originalDescriptor);
    // self-test: now the key/descriptor should be contained
    assertThat(subject.contains(BINARY_ARTIFACT_KEY), is(true));
    assertThat(subject.contains(originalDescriptor), is(true));
    assertThat(subject.contains(equivalentDescriptor), is(true));
    subject.removeDescriptor(equivalentDescriptor);
    assertThat(subject.contains(equivalentDescriptor), is(false));
    assertThat(subject.contains(originalDescriptor), is(false));
    assertThat(subject.contains(BUNDLE_ARTIFACT_KEY), is(false));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) 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