Search in sources :

Example 31 with IArtifactDescriptor

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

the class CompositeArtifactProviderTestBase method testGetPackedRawArtifact.

@Test
public void testGetPackedRawArtifact() throws Exception {
    IArtifactDescriptor packedBundleB = subject.getArtifactDescriptors(BUNDLE_B_KEY)[0];
    rawTestSink = newRawArtifactSinkFor(packedBundleB);
    status = subject.getRawArtifact(rawTestSink, null);
    assertThat(rawTestSink.md5AsHex(), is(TestRepositoryContent.BUNDLE_B_PACKED_CONTENT_MD5));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) Test(org.junit.Test)

Example 32 with IArtifactDescriptor

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

the class RemoteArtifactTransferPolicyTest method loadDescriptorsFromRepository.

static IArtifactDescriptor[] loadDescriptorsFromRepository(String repository, P2Context p2Context) throws Exception {
    IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) p2Context.getAgent().getService(IArtifactRepositoryManager.SERVICE_NAME);
    File repoPath = ResourceUtil.resourceFile("repositories/rawformats/" + repository);
    IArtifactRepository loadedRepo = repoManager.loadRepository(repoPath.toURI(), new NullProgressMonitor());
    return loadedRepo.getArtifactDescriptors(DEFAULT_KEY);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IArtifactRepositoryManager(org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) File(java.io.File)

Example 33 with IArtifactDescriptor

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

the class PackedFormatMirroringArtifactProvider method downloadMostSpecificNeededFormatOfArtifact.

@Override
protected IStatus downloadMostSpecificNeededFormatOfArtifact(IArtifactKey key) throws ProvisionException, ArtifactSinkException {
    IArtifactDescriptor[] allDescriptors = remoteProviders.getArtifactDescriptors(key);
    IArtifactDescriptor packedDescriptor = findPackedDescriptor(allDescriptors);
    if (packedDescriptor != null) {
        // TODO 393004 remove "maven-groupId", etc. properties to force storage as p2/osgi/bundle...
        return downloadRawArtifact(packedDescriptor);
    } else {
        logger.debug("No remote repository provides " + key.getId() + "_" + key.getVersion() + " in packed format. Only the canonical format will be available in the build.");
        return downloadCanonicalArtifact(key);
    }
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)

Example 34 with IArtifactDescriptor

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

the class RepositoryArtifactProviderTest method testGetArtifactWithInfiniteMirrorFailures.

@Test
public void testGetArtifactWithInfiniteMirrorFailures() throws Exception {
    IArtifactRepository failingMirrorsRepository = createArtifactRepositoryMock();
    when(failingMirrorsRepository.contains(BUNDLE_A_KEY)).thenReturn(true);
    when(failingMirrorsRepository.getArtifactDescriptors(BUNDLE_A_KEY)).thenReturn(new IArtifactDescriptor[] { canonicalDescriptorFor(BUNDLE_A_KEY) });
    when(failingMirrorsRepository.getArtifact(argThat(is(canonicalDescriptorFor(BUNDLE_A_KEY))), any(OutputStream.class), any(IProgressMonitor.class))).thenReturn(errorWithRetry("mirror failure"));
    subject = new RepositoryArtifactProvider(Collections.singletonList(failingMirrorsRepository), TRANSFER_POLICY);
    testSink = newArtifactSinkFor(BUNDLE_A_KEY);
    // should give up if all mirrors fail
    status = subject.getArtifact(testSink, null);
    assertThat(status, is(errorStatus()));
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) OutputStream(java.io.OutputStream) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Example 35 with IArtifactDescriptor

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

the class ModuleArtifactRepository method load.

private void load() throws ProvisionException {
    try {
        FileInputStream p2DataFileStream = new FileInputStream(p2DataFile);
        try {
            Set<IArtifactDescriptor> descriptors = new ArtifactsIO().readXML(p2DataFileStream);
            for (IArtifactDescriptor descriptor : descriptors) {
                ModuleArtifactDescriptor internalDescriptor = getInternalDescriptorFromLoadedDescriptor(descriptor, p2DataFile);
                // TODO check that GAV properties match module GAV
                internalAddInternalDescriptor(internalDescriptor);
            }
        } finally {
            p2DataFileStream.close();
        }
    } catch (IOException e) {
        throw failedReadException(p2DataFile, null, e);
    }
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ArtifactsIO(org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) ModuleArtifactDescriptor(org.eclipse.tycho.repository.module.ModuleArtifactRepository.ModuleArtifactDescriptor)

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