Search in sources :

Example 16 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.

the class PomPeek method createCoordinateInfo.

private boolean createCoordinateInfo() {
    String v = elementValues.get(V);
    final String pv = elementValues.get(PV);
    if (isEmpty(v)) {
        v = pv;
    }
    String g = elementValues.get(G);
    final String pg = elementValues.get(PG);
    if (isEmpty(g)) {
        g = pg;
    }
    final String a = elementValues.get(A);
    final String pa = elementValues.get(PA);
    boolean valid = false;
    if (isValidArtifactId(a) && isValidGroupId(g) && isValidVersion(v)) {
        key = new SimpleProjectVersionRef(g, a, v);
        valid = true;
    }
    if (isValidArtifactId(pa) && isValidGroupId(pg) && isValidVersion(pv)) {
        parentKey = new SimpleProjectVersionRef(pg, pa, pv);
    }
    return valid;
}
Also used : SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)

Example 17 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.

the class XMLInfrastructure method getParentRef.

public ProjectVersionRef getParentRef(final Document doc) throws GalleyMavenXMLException {
    final Element project = doc.getDocumentElement();
    final NodeList nl = project.getElementsByTagName("parent");
    if (nl == null || nl.getLength() < 1) {
        logger.debug("No parent declaration.");
        return null;
    }
    final Element parent = (Element) nl.item(0);
    final String gid = getChildText("groupId", parent);
    final String aid = getChildText("artifactId", parent);
    final String ver = getChildText("version", parent);
    if (isEmpty(gid) || isEmpty(aid) || isEmpty(ver)) {
        throw new GalleyMavenXMLException("Project parent is present but invalid! (g=%s,  a=%s, v=%s)", gid, aid, ver);
    }
    return new SimpleProjectVersionRef(gid, aid, ver);
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)

Example 18 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.

the class ArtifactManagerImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy() throws Exception {
    final String base = "single-snapshot/";
    final String testResource = base + "single-snapshot.xml";
    final String testPomResource = base + "single-snapshot-pom.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT");
    final ConcreteResource metadataResource = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
    final ConcreteResource pomResource = new ConcreteResource(LOCATION, fixture.pomPath(ref.selectVersion("1.0-20140604.101244-1").asPomArtifact()));
    fixture.getTransport().registerDownload(metadataResource, new TestDownload(ROOT + testResource));
    fixture.getTransport().registerDownload(pomResource, new TestDownload(ROOT + testPomResource));
    final Transfer retrieved = fixture.getArtifactManager().retrieve(LOCATION, ref.asPomArtifact(), new EventMetadata());
    final Document document = fixture.getXml().parse(retrieved, new EventMetadata());
    final ProjectVersionRef result = fixture.getXml().getProjectVersionRef(document);
    System.out.println(result);
//        assertThat( result, notNullValue() );
//        assertThat( result.getVersionString(), equalTo( "1.0-20140604.101244-1" ) );
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Document(org.w3c.dom.Document) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 19 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.

the class VersionResolverImplTest method resolveSnapshot_FirstMatch_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_FirstMatch_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy() throws Exception {
    final String testResource = "2-snapshots-2-locations/maven-metadata-1.xml";
    final String testResource2 = "2-snapshots-2-locations/maven-metadata-2.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
    final String path = fixture.snapshotMetadataPath(ref);
    fixture.getTransport().registerDownload(new ConcreteResource(LOCATION, path), new TestDownload(ROOT + testResource));
    fixture.getTransport().registerDownload(new ConcreteResource(LOCATION2, path), new TestDownload(ROOT + testResource2));
    final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(TWO_LOCATIONS, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
    assertThat(result, notNullValue());
    // newest snapshot is in the SECOND location, but we're using first-match semantics here.
    assertThat(result.getVersionString(), equalTo("1.0-20140604.101244-1"));
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 20 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.

the class VersionResolverImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy.

@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy() throws Exception {
    final String testResource = "2-snapshots-1-location/two-snapshots.xml";
    final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
    final ConcreteResource cr = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
    final TestDownload download = new TestDownload(ROOT + testResource);
    fixture.getTransport().registerDownload(cr, download);
    final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(ONE_LOCATION, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
    assertThat(result, notNullValue());
    assertThat(result.getVersionString(), equalTo("1.0-20140604.102909-1"));
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Aggregations

SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)21 Test (org.junit.Test)18 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)14 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)12 Transfer (org.commonjava.maven.galley.model.Transfer)11 TestDownload (org.commonjava.maven.galley.testing.core.transport.job.TestDownload)11 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)8 SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)7 URI (java.net.URI)5 LinkedHashMap (java.util.LinkedHashMap)5 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)5 MavenPomView (org.commonjava.maven.galley.maven.model.view.MavenPomView)5 Location (org.commonjava.maven.galley.model.Location)5 EProjectDirectRelationships (org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships)3 ProjectRelationship (org.commonjava.maven.atlas.graph.rel.ProjectRelationship)3 PluginView (org.commonjava.maven.galley.maven.model.view.PluginView)3 InputStream (java.io.InputStream)2 StoreResource (org.commonjava.indy.content.StoreResource)2 SingleVersion (org.commonjava.maven.atlas.ident.version.SingleVersion)2 PluginDependencyView (org.commonjava.maven.galley.maven.model.view.PluginDependencyView)2