Search in sources :

Example 36 with ProjectVersionRef

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

the class PomPeekTest method findGAVInheritedFromParentWithGroupAndVersionOverrideAtTop.

@Test
public void findGAVInheritedFromParentWithGroupAndVersionOverrideAtTop() throws Exception {
    final File pom = getResourceFile(BASE + "inherited-gav-with-group-override-at-top.pom");
    final PomPeek peek = new PomPeek(pom);
    final ProjectVersionRef key = peek.getKey();
    assertThat(key, notNullValue());
    assertThat(key.getGroupId(), equalTo("a-different-test-group"));
    assertThat(key.getArtifactId(), equalTo("inherited-gav-with-group-override-at-top"));
    assertThat(key.getVersionString(), equalTo("1"));
}
Also used : ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) PomPeek(org.commonjava.maven.galley.maven.parse.PomPeek) File(java.io.File) Test(org.junit.Test)

Example 37 with ProjectVersionRef

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

the class PomPeekTest method findGAVInheritedFromParentWithVersionOverrideAtTop.

@Test
public void findGAVInheritedFromParentWithVersionOverrideAtTop() {
    final File pom = getResourceFile(BASE + "inherited-gav-with-override-at-top.pom");
    final PomPeek peek = new PomPeek(pom);
    assertThat(peek.getKey(), notNullValue());
    final ProjectVersionRef key = peek.getKey();
    assertThat(key.getGroupId(), equalTo("test"));
    assertThat(key.getArtifactId(), equalTo("inherited-gav-with-override-at-top"));
    assertThat(key.getVersionString(), equalTo("2"));
}
Also used : ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) PomPeek(org.commonjava.maven.galley.maven.parse.PomPeek) File(java.io.File) Test(org.junit.Test)

Example 38 with ProjectVersionRef

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

the class PomPeekTest method findGAVInheritedFromParentAtTop.

@Test
public void findGAVInheritedFromParentAtTop() {
    final File pom = getResourceFile(BASE + "inherited-gav-at-top.pom");
    final PomPeek peek = new PomPeek(pom);
    assertThat(peek.getKey(), notNullValue());
    final ProjectVersionRef key = peek.getKey();
    assertThat(key.getGroupId(), equalTo("test"));
    assertThat(key.getArtifactId(), equalTo("inherited-gav-at-top"));
    assertThat(key.getVersionString(), equalTo("1"));
}
Also used : ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) PomPeek(org.commonjava.maven.galley.maven.parse.PomPeek) File(java.io.File) Test(org.junit.Test)

Example 39 with ProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.ProjectVersionRef in project indy by Commonjava.

the class AbstractSkimFunctionalTest method loadPom.

protected PomRef loadPom(final String name, final Map<String, String> substitutions) {
    try {
        final InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name + ".pom");
        String pom = IOUtils.toString(stream);
        IOUtils.closeQuietly(stream);
        for (final Map.Entry<String, String> entry : substitutions.entrySet()) {
            pom = pom.replace("@" + entry.getKey() + "@", entry.getValue());
        }
        final PomPeek peek = new PomPeek(pom, false);
        final ProjectVersionRef gav = peek.getKey();
        final String path = String.format("%s/%s/%s/%s-%s.pom", gav.getGroupId().replace('.', '/'), gav.getArtifactId(), gav.getVersionString(), gav.getArtifactId(), gav.getVersionString());
        return new PomRef(pom, path);
    } catch (final Exception e) {
        e.printStackTrace();
        fail("Failed to read POM from: " + name);
    }
    return null;
}
Also used : InputStream(java.io.InputStream) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) PomPeek(org.commonjava.maven.galley.maven.parse.PomPeek) Map(java.util.Map) IOException(java.io.IOException)

Example 40 with ProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.ProjectVersionRef in project indy by Commonjava.

the class HttpProxyTest method loadPom.

protected PomRef loadPom(final String name, final Map<String, String> substitutions) {
    try {
        final String resource = name.endsWith(".pom") ? name : name + ".pom";
        logger.info("Loading POM: {}", resource);
        final InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        String pom = IOUtils.toString(stream);
        IOUtils.closeQuietly(stream);
        for (final Map.Entry<String, String> entry : substitutions.entrySet()) {
            pom = pom.replace("@" + entry.getKey() + "@", entry.getValue());
        }
        final PomPeek peek = new PomPeek(pom, false);
        final ProjectVersionRef gav = peek.getKey();
        final String path = String.format("%s/%s/%s/%s-%s.pom", gav.getGroupId().replace('.', '/'), gav.getArtifactId(), gav.getVersionString(), gav.getArtifactId(), gav.getVersionString());
        return new PomRef(pom, path);
    } catch (final Exception e) {
        e.printStackTrace();
        fail("Failed to read POM from: " + name);
    }
    return null;
}
Also used : InputStream(java.io.InputStream) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) PomPeek(org.commonjava.maven.galley.maven.parse.PomPeek) Map(java.util.Map)

Aggregations

ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)42 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)22 Test (org.junit.Test)22 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)12 TestDownload (org.commonjava.maven.galley.testing.core.transport.job.TestDownload)11 MavenPomView (org.commonjava.maven.galley.maven.model.view.MavenPomView)10 URI (java.net.URI)9 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)9 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)9 Transfer (org.commonjava.maven.galley.model.Transfer)9 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)8 PomPeek (org.commonjava.maven.galley.maven.parse.PomPeek)8 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)6 Document (org.w3c.dom.Document)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 LinkedHashMap (java.util.LinkedHashMap)5 EProjectDirectRelationships (org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships)5 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)5 PluginDependencyView (org.commonjava.maven.galley.maven.model.view.PluginDependencyView)5