Search in sources :

Example 1 with FeatureRootfileArtifactRepository

use of org.eclipse.tycho.p2.impl.publisher.repo.FeatureRootfileArtifactRepository in project tycho by eclipse.

the class FeatureRootfileArtifactRepositoryTest method testRepoWithAttachedArtifactsAndConfigurations.

@Test
public void testRepoWithAttachedArtifactsAndConfigurations() throws Exception {
    FeatureRootfileArtifactRepository subject = new FeatureRootfileArtifactRepository(createPublisherInfo(true), tempFolder.newFolder("testrootfiles"));
    IArtifactDescriptor artifactDescriptor = createArtifactDescriptor(PublisherHelper.BINARY_ARTIFACT_CLASSIFIER, "org.eclipse.tycho.test.p2.win32.win32.x86");
    subject.getOutputStream(artifactDescriptor).close();
    assertAttachedArtifact(subject.getPublishedArtifacts(), 1, "root.win32.win32.x86", "org.eclipse.tycho.test.p2.win32.win32.x86-1.0.0-root.zip");
    Set<IArtifactDescriptor> artifactDescriptors = subject.getArtifactDescriptors();
    Assert.assertEquals(1, artifactDescriptors.size());
    IArtifactDescriptor descriptor = artifactDescriptors.iterator().next();
    assertMavenProperties(descriptor, "root.win32.win32.x86");
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) FeatureRootAdviceTest(org.eclipse.tycho.p2.impl.publisher.rootfiles.FeatureRootAdviceTest) Test(org.junit.Test)

Example 2 with FeatureRootfileArtifactRepository

use of org.eclipse.tycho.p2.impl.publisher.repo.FeatureRootfileArtifactRepository in project tycho by eclipse.

the class FeatureRootfileArtifactRepositoryTest method testRepoWithoutMavenAdvice.

@Test(expected = ProvisionException.class)
public void testRepoWithoutMavenAdvice() throws Exception {
    FeatureRootfileArtifactRepository subject = new FeatureRootfileArtifactRepository(createPublisherInfo(false), tempFolder.newFolder("testrootfiles"));
    IArtifactDescriptor artifactDescriptor = createArtifactDescriptor(PublisherHelper.BINARY_ARTIFACT_CLASSIFIER, "org.eclipse.tycho.test.p2");
    subject.getOutputStream(artifactDescriptor).close();
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) FeatureRootAdviceTest(org.eclipse.tycho.p2.impl.publisher.rootfiles.FeatureRootAdviceTest) Test(org.junit.Test)

Example 3 with FeatureRootfileArtifactRepository

use of org.eclipse.tycho.p2.impl.publisher.repo.FeatureRootfileArtifactRepository in project tycho by eclipse.

the class FeatureRootfileArtifactRepositoryTest method testRepoWithAttachedArtifacts.

@Test
public void testRepoWithAttachedArtifacts() throws Exception {
    FeatureRootfileArtifactRepository subject = new FeatureRootfileArtifactRepository(createPublisherInfo(true), tempFolder.newFolder("testrootfiles"));
    IArtifactDescriptor artifactDescriptor = createArtifactDescriptor(PublisherHelper.BINARY_ARTIFACT_CLASSIFIER, "org.eclipse.tycho.test.p2");
    subject.getOutputStream(artifactDescriptor).close();
    assertAttachedArtifact(subject.getPublishedArtifacts(), 1, "root", "org.eclipse.tycho.test.p2-1.0.0-root.zip");
    Set<IArtifactDescriptor> artifactDescriptors = subject.getArtifactDescriptors();
    Assert.assertEquals(1, artifactDescriptors.size());
    IArtifactDescriptor descriptor = artifactDescriptors.iterator().next();
    assertMavenProperties(descriptor, "root");
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) FeatureRootAdviceTest(org.eclipse.tycho.p2.impl.publisher.rootfiles.FeatureRootAdviceTest) Test(org.junit.Test)

Example 4 with FeatureRootfileArtifactRepository

use of org.eclipse.tycho.p2.impl.publisher.repo.FeatureRootfileArtifactRepository in project tycho by eclipse.

the class P2GeneratorImpl method generateMetadata.

@Override
public Map<String, IP2Artifact> generateMetadata(List<IArtifactFacade> artifacts, final File targetDir) throws IOException {
    Map<String, IP2Artifact> result = new LinkedHashMap<>();
    for (IArtifactFacade artifact : artifacts) {
        PublisherInfo publisherInfo = new PublisherInfo();
        DependencyMetadata metadata;
        // meta data handling for root files
        if (PackagingType.TYPE_ECLIPSE_FEATURE.equals(artifact.getPackagingType())) {
            publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX | IPublisherInfo.A_PUBLISH | IPublisherInfo.A_NO_MD5);
            FeatureRootfileArtifactRepository artifactsRepository = new FeatureRootfileArtifactRepository(publisherInfo, targetDir);
            publisherInfo.setArtifactRepository(artifactsRepository);
            metadata = super.generateMetadata(artifact, null, publisherInfo, null);
            result.putAll(artifactsRepository.getPublishedArtifacts());
        } else if (PackagingType.TYPE_P2_IU.equals(artifact.getPackagingType())) {
            TransientArtifactRepository artifactsRepository = new TransientArtifactRepository();
            publisherInfo.setArtifactRepository(artifactsRepository);
            final IArtifactFacade currentArtifact = artifact;
            IArtifactFacade targetDirAsArtifact = new IArtifactFacade() {

                @Override
                public String getVersion() {
                    return currentArtifact.getVersion();
                }

                @Override
                public String getPackagingType() {
                    return currentArtifact.getPackagingType();
                }

                @Override
                public File getLocation() {
                    return targetDir;
                }

                @Override
                public String getGroupId() {
                    return currentArtifact.getGroupId();
                }

                @Override
                public String getClassifier() {
                    return currentArtifact.getClassifier();
                }

                @Override
                public String getArtifactId() {
                    return currentArtifact.getArtifactId();
                }
            };
            metadata = super.generateMetadata(targetDirAsArtifact, null, publisherInfo, null);
        } else {
            publisherInfo.setArtifactOptions(IPublisherInfo.A_PUBLISH | IPublisherInfo.A_NO_MD5);
            TransientArtifactRepository artifactsRepository = new TransientArtifactRepository();
            publisherInfo.setArtifactRepository(artifactsRepository);
            metadata = super.generateMetadata(artifact, null, publisherInfo, null);
        }
        // secondary metadata is meant to represent installable units that are provided by this project
        // but do not affect dependencies of the project itself. generateMetadata is called at the end
        // of project build lifecycle, and primary/secondary metadata separation is irrelevant at this point
        P2Artifact p2artifact = new P2Artifact(artifact.getLocation(), metadata.getInstallableUnits(), getCanonicalArtifact(artifact.getClassifier(), metadata.getArtifactDescriptors()));
        result.put(artifact.getClassifier(), p2artifact);
        IArtifactDescriptor packed = getPackedArtifactDescriptor(metadata.getArtifactDescriptors());
        if (packed != null) {
            File packedLocation = new File(artifact.getLocation().getAbsolutePath() + ".pack.gz");
            if (!packedLocation.canRead()) {
                throw new IllegalArgumentException("Could not find packed artifact " + packed + " at " + packedLocation);
            }
            if (result.containsKey(RepositoryLayoutHelper.PACK200_CLASSIFIER)) {
                throw new IllegalArgumentException();
            }
            // workaround for bug 412497
            Map<String, String> additionalProperties = new HashMap<>(5);
            additionalProperties.put(RepositoryLayoutHelper.PROP_GROUP_ID, artifact.getGroupId());
            additionalProperties.put(RepositoryLayoutHelper.PROP_ARTIFACT_ID, artifact.getArtifactId());
            additionalProperties.put(RepositoryLayoutHelper.PROP_VERSION, artifact.getVersion());
            additionalProperties.put(RepositoryLayoutHelper.PROP_CLASSIFIER, RepositoryLayoutHelper.PACK200_CLASSIFIER);
            additionalProperties.put(RepositoryLayoutHelper.PROP_EXTENSION, RepositoryLayoutHelper.PACK200_EXTENSION);
            ((ArtifactDescriptor) packed).addProperties(additionalProperties);
            result.put(RepositoryLayoutHelper.PACK200_CLASSIFIER, new P2Artifact(packedLocation, Collections.<IInstallableUnit>emptySet(), packed));
        }
    }
    return result;
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactFacade(org.eclipse.tycho.p2.metadata.IArtifactFacade) IPublisherInfo(org.eclipse.equinox.p2.publisher.IPublisherInfo) PublisherInfo(org.eclipse.equinox.p2.publisher.PublisherInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FeatureRootfileArtifactRepository(org.eclipse.tycho.p2.impl.publisher.repo.FeatureRootfileArtifactRepository) TransientArtifactRepository(org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository) LinkedHashMap(java.util.LinkedHashMap) ArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor) IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File)

Example 5 with FeatureRootfileArtifactRepository

use of org.eclipse.tycho.p2.impl.publisher.repo.FeatureRootfileArtifactRepository in project tycho by eclipse.

the class FeatureRootfileArtifactRepositoryTest method testRepoForNonBinaryArtifacts.

@Test
public void testRepoForNonBinaryArtifacts() throws Exception {
    FeatureRootfileArtifactRepository subject = new FeatureRootfileArtifactRepository(createPublisherInfo(true), tempFolder.newFolder("testrootfiles"));
    IArtifactDescriptor artifactDescriptor = createArtifactDescriptor("non-binary-classifier", "org.eclipse.tycho.test.p2");
    subject.getOutputStream(artifactDescriptor).close();
    Map<String, IP2Artifact> attachedArtifacts = subject.getPublishedArtifacts();
    Assert.assertEquals(0, attachedArtifacts.size());
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IP2Artifact(org.eclipse.tycho.p2.metadata.IP2Artifact) FeatureRootAdviceTest(org.eclipse.tycho.p2.impl.publisher.rootfiles.FeatureRootAdviceTest) Test(org.junit.Test)

Aggregations

IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)5 FeatureRootAdviceTest (org.eclipse.tycho.p2.impl.publisher.rootfiles.FeatureRootAdviceTest)4 Test (org.junit.Test)4 IP2Artifact (org.eclipse.tycho.p2.metadata.IP2Artifact)2 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)1 PublisherInfo (org.eclipse.equinox.p2.publisher.PublisherInfo)1 ArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor)1 FeatureRootfileArtifactRepository (org.eclipse.tycho.p2.impl.publisher.repo.FeatureRootfileArtifactRepository)1 TransientArtifactRepository (org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository)1 IArtifactFacade (org.eclipse.tycho.p2.metadata.IArtifactFacade)1