Search in sources :

Example 6 with IArtifactKey

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

the class CompositeArtifactProvider method getArtifactFromAnySource.

@Override
protected void getArtifactFromAnySource(IArtifactSink sink, List<IStatus> statusCollector, IProgressMonitor monitor) throws ArtifactSinkException {
    IArtifactKey requestedKey = sink.getArtifactToBeWritten();
    for (IRawArtifactFileProvider component : components) {
        if (component.contains(requestedKey)) {
            if (!sink.canBeginWrite()) {
                return;
            }
            IStatus transferStatus = component.getArtifact(sink, monitor);
            statusCollector.add(transferStatus);
            if (!isFatal(transferStatus)) {
                // read was successful -> done
                return;
            }
        }
    }
}
Also used : IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) IStatus(org.eclipse.core.runtime.IStatus)

Example 7 with IArtifactKey

use of org.eclipse.equinox.p2.metadata.IArtifactKey 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 8 with IArtifactKey

use of org.eclipse.equinox.p2.metadata.IArtifactKey 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 9 with IArtifactKey

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

the class AuthoredIUAction method perform.

@Override
@SuppressWarnings("deprecation")
public IStatus perform(IPublisherInfo info, IPublisherResult results, IProgressMonitor monitor) {
    File iuFile = new File(iuProject, "p2iu.xml");
    if (!iuFile.exists())
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not find the p2iu.xml file in folder " + iuProject);
    try {
        FileInputStream is = new FileInputStream(iuFile);
        InstallableUnitDescription iuDescriptions = new MetadataIO().readOneIU(is);
        tweakIU(iuDescriptions);
        Set<IInstallableUnit> ius = toIUs(iuDescriptions);
        results.addIUs(ius, IPublisherResult.ROOT);
        IArtifactRepository repo = info.getArtifactRepository();
        boolean artifactReferenced = false;
        if (repo != null) {
            for (IInstallableUnit iu : ius) {
                Collection<IArtifactKey> associatedKeys = iu.getArtifacts();
                for (IArtifactKey key : associatedKeys) {
                    ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, key, null);
                    processArtifactPropertiesAdvice(iu, ad, info);
                    ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP);
                    ad.setProperty(RepositoryLayoutHelper.PROP_EXTENSION, "zip");
                    repo.addDescriptor(ad);
                    artifactReferenced = true;
                }
            }
        }
        // and fails in many places. I tried to change the code where the failures were occurring but did not succeed.
        if (!artifactReferenced && repo != null) {
            IInstallableUnit iu = ((IInstallableUnit) ius.iterator().next());
            ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, new ArtifactKey("binary", "generated_" + iu.getId(), iu.getVersion()), null);
            processArtifactPropertiesAdvice(iu, ad, info);
            ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP);
            repo.addDescriptor(ad);
            artifactReferenced = true;
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error while reading " + iuFile, e);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) ArtifactKey(org.eclipse.equinox.internal.p2.metadata.ArtifactKey) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File)

Example 10 with IArtifactKey

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

the class TargetPlatformBundlePublisherTest method artifactMD5Of.

private static String artifactMD5Of(IArtifactKey key, IRawArtifactProvider artifactProvider) throws Exception {
    ProbeRawArtifactSink probeSink = ProbeRawArtifactSink.newRawArtifactSinkFor(new ArtifactDescriptor(key));
    artifactProvider.getArtifact(probeSink, null);
    return probeSink.md5AsHex();
}
Also used : ProbeRawArtifactSink(org.eclipse.tycho.repository.streaming.testutil.ProbeRawArtifactSink) ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)

Aggregations

IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)13 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)11 File (java.io.File)6 IStatus (org.eclipse.core.runtime.IStatus)6 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 BufferedOutputStream (java.io.BufferedOutputStream)3 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 OutputStream (java.io.OutputStream)3 Status (org.eclipse.core.runtime.Status)3 ArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor)3 Test (org.junit.Test)3 ArtifactKey (org.eclipse.equinox.internal.p2.metadata.ArtifactKey)2 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)2 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)2 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)2 IProcessingStepDescriptor (org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor)2 ProcessingStepDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor)2 P2Artifact (org.eclipse.tycho.p2.impl.publisher.P2Artifact)2 IArtifactFacade (org.eclipse.tycho.p2.metadata.IArtifactFacade)2