Search in sources :

Example 6 with MavenRepositoryCoordinates

use of org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates in project tycho by eclipse.

the class GAVArtifactDescriptorTest method testSerializationRoundTrip.

@Test
public void testSerializationRoundTrip() {
    MavenRepositoryCoordinates coordinates = new MavenRepositoryCoordinates(TEST_GAV, OTHER_CLASSIFIER, OTHER_EXTENSION);
    GAVArtifactDescriptor original = new GAVArtifactDescriptor(createP2Descriptor(), coordinates);
    subject = serializeAndDeSerialize(original);
    assertThat(subject.getArtifactKey(), is(TEST_KEY));
    assertThat(subject.getMavenCoordinates(), is(coordinates));
}
Also used : MavenRepositoryCoordinates(org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates) Test(org.junit.Test)

Example 7 with MavenRepositoryCoordinates

use of org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates in project tycho by eclipse.

the class GAVArtifactDescriptor method getP2DerivedCoordinates.

/**
 * @return fake Maven coordinates derived from the given key; never <code>null</code>
 */
private static MavenRepositoryCoordinates getP2DerivedCoordinates(IArtifactKey key, Map<String, String> properties) {
    GAV gav = RepositoryLayoutHelper.getP2Gav(key.getClassifier(), key.getId(), key.getVersion().toString());
    String classifier = null;
    String extension = RepositoryLayoutHelper.DEFAULT_EXTERNSION;
    if (properties != null && IArtifactDescriptor.FORMAT_PACKED.equals(properties.get(IArtifactDescriptor.FORMAT))) {
        classifier = RepositoryLayoutHelper.PACK200_CLASSIFIER;
        extension = RepositoryLayoutHelper.PACK200_EXTENSION;
    }
    return new MavenRepositoryCoordinates(gav, classifier, extension);
}
Also used : MavenRepositoryCoordinates(org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates) GAV(org.eclipse.tycho.p2.repository.GAV)

Example 8 with MavenRepositoryCoordinates

use of org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates in project tycho by eclipse.

the class ModuleArtifactRepository method createArtifactDescriptor.

public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key, WriteSessionContext writeSession) {
    ClassifierAndExtension additionalProperties = writeSession.getClassifierAndExtensionForNewKey(key);
    MavenRepositoryCoordinates mavenCoordinates = new MavenRepositoryCoordinates(moduleGAV, additionalProperties.classifier, additionalProperties.fileExtension);
    return new ModuleArtifactDescriptor(key, mavenCoordinates);
}
Also used : MavenRepositoryCoordinates(org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates) ClassifierAndExtension(org.eclipse.tycho.repository.publishing.WriteSessionContext.ClassifierAndExtension) ModuleArtifactDescriptor(org.eclipse.tycho.repository.module.ModuleArtifactRepository.ModuleArtifactDescriptor)

Example 9 with MavenRepositoryCoordinates

use of org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates in project tycho by eclipse.

the class ModuleArtifactRepository method getInternalDescriptorForAdding.

@Override
protected ModuleArtifactDescriptor getInternalDescriptorForAdding(IArtifactDescriptor descriptor) throws IllegalArgumentException {
    if (descriptor == null) {
        throw new NullPointerException();
    } else if (!(descriptor instanceof ModuleArtifactDescriptor) || descriptor.getRepository() != this) {
        throw new IllegalArgumentException("Cannot add artifact descriptor which has not been created by this repository");
    }
    ModuleArtifactDescriptor internalDescriptor = (ModuleArtifactDescriptor) descriptor;
    try {
        MavenRepositoryCoordinates coordinates = internalDescriptor.getMavenCoordinates();
        artifactsMap.addToAutomaticLocation(coordinates.getClassifier(), coordinates.getExtension());
    } catch (ProvisionException e) {
        // TODO 393004 Revise exception handling
        throw new RuntimeException(e);
    }
    return internalDescriptor;
}
Also used : MavenRepositoryCoordinates(org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) ModuleArtifactDescriptor(org.eclipse.tycho.repository.module.ModuleArtifactRepository.ModuleArtifactDescriptor)

Example 10 with MavenRepositoryCoordinates

use of org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates in project tycho by eclipse.

the class GAVArtifactDescriptorBase method readMavenCoordinateProperties.

/**
 * @return the Maven coordinates stored in the properties of the given descriptor, or
 *         <code>null</code>
 */
public static MavenRepositoryCoordinates readMavenCoordinateProperties(IArtifactDescriptor descriptor) {
    GAV gav = RepositoryLayoutHelper.getGAV(descriptor.getProperties());
    if (gav == null) {
        return null;
    }
    String classifier = RepositoryLayoutHelper.getClassifier(descriptor.getProperties());
    String extension = RepositoryLayoutHelper.getExtension(descriptor.getProperties());
    return new MavenRepositoryCoordinates(gav, classifier, extension);
}
Also used : MavenRepositoryCoordinates(org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates) GAV(org.eclipse.tycho.p2.repository.GAV)

Aggregations

MavenRepositoryCoordinates (org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates)16 Test (org.junit.Test)12 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)8 ArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor)8 GAV (org.eclipse.tycho.p2.repository.GAV)2 ModuleArtifactDescriptor (org.eclipse.tycho.repository.module.ModuleArtifactRepository.ModuleArtifactDescriptor)2 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 ClassifierAndExtension (org.eclipse.tycho.repository.publishing.WriteSessionContext.ClassifierAndExtension)1