use of org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship in project galley by Commonjava.
the class MavenModelProcessor method addDependencyRelationships.
protected void addDependencyRelationships(final URI source, final Builder builder, final MavenPomView pomView, final ProjectVersionRef projectRef, final boolean includeManagedDependencies) {
// regardless of whether we're processing managed info, this is STRUCTURAL, so always grab it!
List<DependencyView> boms = null;
try {
boms = pomView.getAllBOMs();
} catch (final GalleyMavenException e) {
logger.error(String.format("%s: Failed to retrieve BOM declarations: %s. Skipping", pomView.getRef(), e.getMessage()), e);
} catch (final InvalidVersionSpecificationException e) {
logger.error(String.format("%s: Failed to retrieve BOM declarations: %s. Skipping", pomView.getRef(), e.getMessage()), e);
} catch (final InvalidRefException e) {
logger.error(String.format("%s: Failed to retrieve BOM declarations: %s. Skipping", pomView.getRef(), e.getMessage()), e);
}
if (boms != null) {
for (int i = 0; i < boms.size(); i++) {
final DependencyView bomView = boms.get(i);
try {
builder.withBoms(new SimpleBomRelationship(source, projectRef, bomView.asProjectVersionRef(), i, bomView.getOriginInfo().isInherited(), bomView.getOriginInfo().isMixin()));
} catch (final InvalidRefException e) {
logger.error(String.format("%s dependency is invalid! Reason: %s. Skipping:\n\n%s\n\n", pomView.getRef(), e.getMessage(), bomView.toXML()), e);
} catch (final InvalidVersionSpecificationException e) {
logger.error(String.format("%s dependency is invalid! Reason: %s. Skipping:\n\n%s\n\n", pomView.getRef(), e.getMessage(), bomView.toXML()), e);
} catch (final GalleyMavenException e) {
logger.error(String.format("%s dependency is invalid! Reason: %s. Skipping:\n\n%s\n\n", pomView.getRef(), e.getMessage(), bomView.toXML()), e);
}
}
}
if (includeManagedDependencies) {
List<DependencyView> deps = null;
try {
deps = pomView.getAllManagedDependencies();
} catch (final GalleyMavenException e) {
logger.error(String.format("%s: Failed to retrieve managed dependencies: %s. Skipping", pomView.getRef(), e.getMessage()), e);
} catch (final InvalidVersionSpecificationException e) {
logger.error(String.format("%s: Failed to retrieve managed dependencies: %s. Skipping", pomView.getRef(), e.getMessage()), e);
} catch (final InvalidRefException e) {
logger.error(String.format("%s: Failed to retrieve managed dependencies: %s. Skipping", pomView.getRef(), e.getMessage()), e);
}
addDependencies(deps, projectRef, builder, source, true);
}
List<DependencyView> deps = null;
try {
deps = pomView.getAllDirectDependencies();
} catch (final GalleyMavenException e) {
logger.error(String.format("%s: Failed to retrieve direct dependencies: %s. Skipping", pomView.getRef(), e.getMessage()), e);
} catch (final InvalidVersionSpecificationException e) {
logger.error(String.format("%s: Failed to retrieve direct dependencies: %s. Skipping", pomView.getRef(), e.getMessage()), e);
} catch (final InvalidRefException e) {
logger.error(String.format("%s: Failed to retrieve direct dependencies: %s. Skipping", pomView.getRef(), e.getMessage()), e);
}
addDependencies(deps, projectRef, builder, source, false);
}
Aggregations