Search in sources :

Example 1 with SimpleBomRelationship

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);
}
Also used : GalleyMavenException(org.commonjava.maven.galley.maven.GalleyMavenException) InvalidVersionSpecificationException(org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException) SimpleBomRelationship(org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship) InvalidRefException(org.commonjava.maven.atlas.ident.ref.InvalidRefException) PluginDependencyView(org.commonjava.maven.galley.maven.model.view.PluginDependencyView) DependencyView(org.commonjava.maven.galley.maven.model.view.DependencyView)

Aggregations

SimpleBomRelationship (org.commonjava.maven.atlas.graph.rel.SimpleBomRelationship)1 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)1 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)1 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)1 DependencyView (org.commonjava.maven.galley.maven.model.view.DependencyView)1 PluginDependencyView (org.commonjava.maven.galley.maven.model.view.PluginDependencyView)1