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);
}
}
Aggregations