Search in sources :

Example 1 with ParentView

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

the class MavenModelProcessor method addParentRelationship.

protected void addParentRelationship(final URI source, final Builder builder, final MavenPomView pomView, final ProjectVersionRef projectRef) {
    try {
        final ParentView parent = pomView.getParent();
        if (parent != null) {
            final ProjectVersionRef ref = parent.asProjectVersionRef();
            // force the InvalidVersionSpecificationException.
            ref.getVersionSpec();
            logger.info("Adding parent relationship for: {} to : {}", builder.getProjectRef(), ref);
            builder.withParent(new SimpleParentRelationship(source, builder.getProjectRef(), ref));
        } else {
            logger.info("Adding self-referential parent relationship for: {} to signify project has no parent, but is parsable.", builder.getProjectRef());
            builder.withParent(new SimpleParentRelationship(builder.getProjectRef()));
        }
    } catch (final GalleyMavenException e) {
        logger.error(String.format("%s: Parent reference is invalid! Reason: %s. Skipping.", projectRef, e.getMessage()), e);
    } catch (final InvalidVersionSpecificationException e) {
        logger.error(String.format("%s: Parent reference is invalid! Reason: %s. Skipping.", projectRef, e.getMessage()), e);
    } catch (final InvalidRefException e) {
        logger.error(String.format("%s: Parent reference is invalid! Reason: %s. Skipping.", projectRef, e.getMessage()), e);
    }
}
Also used : ParentView(org.commonjava.maven.galley.maven.model.view.ParentView) GalleyMavenException(org.commonjava.maven.galley.maven.GalleyMavenException) InvalidVersionSpecificationException(org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) InvalidRefException(org.commonjava.maven.atlas.ident.ref.InvalidRefException) SimpleParentRelationship(org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship)

Aggregations

SimpleParentRelationship (org.commonjava.maven.atlas.graph.rel.SimpleParentRelationship)1 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)1 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)1 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)1 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)1 ParentView (org.commonjava.maven.galley.maven.model.view.ParentView)1