Search in sources :

Example 6 with PomPeek

use of org.commonjava.maven.galley.maven.parse.PomPeek 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 7 with PomPeek

use of org.commonjava.maven.galley.maven.parse.PomPeek 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 8 with PomPeek

use of org.commonjava.maven.galley.maven.parse.PomPeek 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)

Example 9 with PomPeek

use of org.commonjava.maven.galley.maven.parse.PomPeek in project indy by Commonjava.

the class AbstractHttproxFunctionalTest method loadPom.

protected PomRef loadPom(final String name, final Map<String, String> substitutions) {
    try {
        final InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name.endsWith(".pom") ? name : 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)

Aggregations

PomPeek (org.commonjava.maven.galley.maven.parse.PomPeek)9 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)8 File (java.io.File)6 Test (org.junit.Test)6 InputStream (java.io.InputStream)3 Map (java.util.Map)3 IOException (java.io.IOException)2