Search in sources :

Example 6 with DocRef

use of org.commonjava.maven.galley.maven.model.view.DocRef in project galley by Commonjava.

the class MavenPomReader method read.

public MavenPomView read(final ProjectVersionRef ref, final Transfer pom, final List<? extends Location> locations, final EventMetadata eventMetadata, final String... activeProfileLocations) throws GalleyMavenException {
    final List<DocRef<ProjectVersionRef>> stack = new ArrayList<DocRef<ProjectVersionRef>>();
    DocRef<ProjectVersionRef> dr;
    try {
        dr = getDocRef(ref, pom, false, eventMetadata);
    } catch (final TransferException e) {
        throw new GalleyMavenException("Failed to retrieve POM for: {}, {} levels deep in ancestry stack of: {}. Reason: {}", e, ref, stack.size(), ref, e.getMessage());
    }
    stack.add(dr);
    ProjectVersionRef next = xml.getParentRef(dr.getDoc());
    while (next != null && dr != null) {
        try {
            dr = getDocRef(next, locations, false, eventMetadata);
        } catch (final TransferException e) {
            throw new GalleyMavenException("Failed to retrieve POM for: {}, {} levels deep in ancestry stack of: {}. Reason: {}", e, next, stack.size(), ref, e.getMessage());
        }
        if (dr == null) {
            throw new GalleyMavenException("Cannot resolve {}, {} levels dep in the ancestry stack of: {}", next, stack.size(), ref);
        }
        stack.add(dr);
        next = xml.getParentRef(dr.getDoc());
    }
    final MavenPomView view = new MavenPomView(ref, stack, xpath, pluginDefaults, pluginImplications, xml, activeProfileLocations);
    assembleImportedInformation(view, locations);
    logStructure(view);
    return view;
}
Also used : TransferException(org.commonjava.maven.galley.TransferException) GalleyMavenException(org.commonjava.maven.galley.maven.GalleyMavenException) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ArrayList(java.util.ArrayList) DocRef(org.commonjava.maven.galley.maven.model.view.DocRef) MavenPomView(org.commonjava.maven.galley.maven.model.view.MavenPomView)

Aggregations

DocRef (org.commonjava.maven.galley.maven.model.view.DocRef)6 ArrayList (java.util.ArrayList)4 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)4 TransferException (org.commonjava.maven.galley.TransferException)3 Location (org.commonjava.maven.galley.model.Location)3 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)2 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)2 MavenPomView (org.commonjava.maven.galley.maven.model.view.MavenPomView)2 File (java.io.File)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ProjectRef (org.commonjava.maven.atlas.ident.ref.ProjectRef)1 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)1 MavenMetadataView (org.commonjava.maven.galley.maven.model.view.meta.MavenMetadataView)1 MavenSettingsView (org.commonjava.maven.galley.maven.model.view.settings.MavenSettingsView)1 Transfer (org.commonjava.maven.galley.model.Transfer)1 Document (org.w3c.dom.Document)1