Search in sources :

Example 11 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.atlas.maven.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)11 File (java.io.File)8 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)7 Test (org.junit.Test)6 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 Map (java.util.Map)3 ProjectVersionRef (org.commonjava.atlas.maven.ident.ref.ProjectVersionRef)3 ArrayList (java.util.ArrayList)2 ManipulationException (org.commonjava.maven.ext.common.ManipulationException)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Model (org.apache.maven.model.Model)1 MavenXpp3Reader (org.apache.maven.model.io.xpp3.MavenXpp3Reader)1 MavenProject (org.apache.maven.project.MavenProject)1 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)1 Project (org.commonjava.maven.ext.common.model.Project)1