Search in sources :

Example 11 with IArtifactKey

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

the class TargetPlatformBundlePublisherTest method testPomDependencyOnBundle.

@Test
public void testPomDependencyOnBundle() throws Exception {
    String bundleId = "org.eclipse.osgi";
    String bundleVersion = "3.5.2.R35x_v20100126";
    FileUtils.copyDirectory(resourceFile("platformbuilder/pom-dependencies/bundle-repo"), localRepositoryRoot);
    File bundleFile = new File(localRepositoryRoot, RepositoryLayoutHelper.getRelativePath(GROUP_ID, ARTIFACT_ID, VERSION, null, "jar"));
    IArtifactFacade bundleArtifact = new ArtifactMock(bundleFile, GROUP_ID, ARTIFACT_ID, VERSION, "jar");
    IInstallableUnit publishedUnit = subject.attemptToPublishBundle(bundleArtifact);
    assertThat(publishedUnit, is(unit(bundleId, bundleVersion)));
    assertThat(publishedUnit.getProperties(), containsGAV(GROUP_ID, ARTIFACT_ID, VERSION));
    assertThat(publishedUnit.getArtifacts().size(), is(1));
    IArtifactKey referencedArtifact = publishedUnit.getArtifacts().iterator().next();
    IRawArtifactProvider artifactRepo = subject.getArtifactRepoOfPublishedBundles();
    assertThat(artifactRepo, contains(referencedArtifact));
    IArtifactDescriptor[] artifactDescriptors = artifactRepo.getArtifactDescriptors(referencedArtifact);
    assertThat(artifactDescriptors.length, is(1));
    assertThat(artifactDescriptors[0].getProperties(), containsGAV(GROUP_ID, ARTIFACT_ID, VERSION));
    assertThat(artifactDescriptors[0].getProperties(), hasProperty("download.md5", "6303323acc98658c0fed307c84db4411"));
    // test that reading the artifact succeeds (because the way it is added to the repository is a bit special)
    assertThat(artifactMD5Of(referencedArtifact, artifactRepo), is("6303323acc98658c0fed307c84db4411"));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactFacade(org.eclipse.tycho.p2.metadata.IArtifactFacade) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IRawArtifactProvider(org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactProvider) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) Test(org.junit.Test)

Example 12 with IArtifactKey

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

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

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

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

the class LocalArtifactRepositoryP2APITest method testRemoveNonContainedKey.

@Test
public void testRemoveNonContainedKey() {
    IArtifactKey keyToRemove = OTHER_KEY;
    subject.removeDescriptor(keyToRemove);
    assertNoChanges();
}
Also used : IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) Test(org.junit.Test)

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