Search in sources :

Example 1 with ArtifactKey

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

the class LocalArtifactRepositoryTest method newBundleArtifactDescriptor.

private ArtifactDescriptor newBundleArtifactDescriptor(boolean maven) {
    ArtifactKey key = new ArtifactKey(PublisherHelper.OSGI_BUNDLE_CLASSIFIER, "org.eclipse.tycho.test." + (maven ? "maven" : "p2"), Version.createOSGi(1, 0, 0));
    ArtifactDescriptor desc = new ArtifactDescriptor(key);
    if (maven) {
        desc.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
        desc.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, key.getId());
        desc.setProperty(RepositoryLayoutHelper.PROP_VERSION, key.getVersion().toString());
    }
    return desc;
}
Also used : IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) ArtifactKey(org.eclipse.equinox.internal.p2.metadata.ArtifactKey) ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)

Example 2 with ArtifactKey

use of org.eclipse.equinox.internal.p2.metadata.ArtifactKey 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 3 with ArtifactKey

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

the class FeatureRootfileArtifactRepositoryTest method createArtifactDescriptor.

private ArtifactDescriptor createArtifactDescriptor(String classifier, String artifactId) {
    ArtifactKey key = new ArtifactKey(classifier, artifactId, Version.createOSGi(1, 0, 0));
    ArtifactDescriptor desc = new ArtifactDescriptor(key);
    return desc;
}
Also used : ArtifactKey(org.eclipse.equinox.internal.p2.metadata.ArtifactKey) ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)

Example 4 with ArtifactKey

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

the class FeatureRootfileArtifactRepository method createRootfileOutputStream.

private OutputStream createRootfileOutputStream(IArtifactKey artifactKey) throws ProvisionException, IOException {
    File outputFile = new File(this.outputDirectory, artifactKey.getId() + "-" + artifactKey.getVersion() + "-" + ROOTFILE_CLASSIFIER + "." + ROOTFILE_EXTENSION);
    OutputStream target = null;
    try {
        SimpleArtifactDescriptor simpleArtifactDescriptor = (SimpleArtifactDescriptor) createArtifactDescriptor(artifactKey);
        Collection<IPropertyAdvice> advices = publisherInfo.getAdvice(null, false, simpleArtifactDescriptor.getArtifactKey().getId(), simpleArtifactDescriptor.getArtifactKey().getVersion(), IPropertyAdvice.class);
        boolean mavenPropAdviceExists = false;
        for (IPropertyAdvice entry : advices) {
            if (entry instanceof MavenPropertiesAdvice) {
                mavenPropAdviceExists = true;
                entry.getArtifactProperties(null, simpleArtifactDescriptor);
            }
        }
        if (!mavenPropAdviceExists) {
            throw new ProvisionException("MavenPropertiesAdvice does not exist for artifact: " + simpleArtifactDescriptor);
        }
        String mavenArtifactClassifier = getRootFileArtifactClassifier(simpleArtifactDescriptor.getArtifactKey().getId());
        simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_CLASSIFIER, mavenArtifactClassifier);
        simpleArtifactDescriptor.setProperty(RepositoryLayoutHelper.PROP_EXTENSION, ROOTFILE_EXTENSION);
        target = new BufferedOutputStream(new FileOutputStream(outputFile));
        this.publishedArtifacts.put(mavenArtifactClassifier, new P2Artifact(outputFile, Collections.<IInstallableUnit>emptySet(), simpleArtifactDescriptor));
        descriptors.add(simpleArtifactDescriptor);
    } catch (FileNotFoundException e) {
        throw new ProvisionException(e.getMessage(), e);
    }
    return target;
}
Also used : BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IPropertyAdvice(org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice) MavenPropertiesAdvice(org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice) FileNotFoundException(java.io.FileNotFoundException) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) FileOutputStream(java.io.FileOutputStream) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) P2Artifact(org.eclipse.tycho.p2.impl.publisher.P2Artifact) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) SimpleArtifactDescriptor(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 5 with ArtifactKey

use of org.eclipse.equinox.internal.p2.metadata.ArtifactKey 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)

Aggregations

ArtifactKey (org.eclipse.equinox.internal.p2.metadata.ArtifactKey)5 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)4 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)3 ArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor)3 File (java.io.File)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 SimpleArtifactDescriptor (org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 Version (org.eclipse.equinox.p2.metadata.Version)1 IPropertyAdvice (org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice)1 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)1