Search in sources :

Example 1 with SimplePluginRelationship

use of org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship in project galley by Commonjava.

the class MavenModelProcessor method addPlugins.

private void addPlugins(final List<PluginView> plugins, final ProjectVersionRef projectRef, final Builder builder, final URI source, final boolean managed) {
    if (plugins != null) {
        for (final PluginView plugin : plugins) {
            ProjectVersionRef pluginRef = null;
            try {
                if (plugin.getVersion() == null) {
                    logger.error("%s: Cannot find a version for plugin: {}. Skipping.", projectRef, plugin.toXML());
                    continue;
                }
                pluginRef = plugin.asProjectVersionRef();
                // force the InvalidVersionSpecificationException.
                pluginRef.getVersionSpec();
                final String profileId = plugin.getProfileId();
                final URI location = RelationshipUtils.profileLocation(profileId);
                boolean inherited = plugin.getOriginInfo().isInherited();
                boolean mixin = plugin.getOriginInfo().isMixin();
                builder.withPlugins(new SimplePluginRelationship(source, location, projectRef, pluginRef, builder.getNextPluginDependencyIndex(projectRef, managed, inherited), managed, inherited));
            } catch (final GalleyMavenException e) {
                logger.error(String.format("%s: plugin is invalid! Reason: %s. Skipping:\n\n%s\n\n", projectRef, e.getMessage(), plugin.toXML()), e);
                continue;
            } catch (final InvalidVersionSpecificationException e) {
                logger.error(String.format("%s: plugin is invalid! Reason: %s. Skipping:\n\n%s\n\n", projectRef, e.getMessage(), plugin.toXML()), e);
                continue;
            } catch (final InvalidRefException e) {
                logger.error(String.format("%s: plugin is invalid! Reason: %s. Skipping:\n\n%s\n\n", projectRef, e.getMessage(), plugin.toXML()), e);
                continue;
            }
            List<PluginDependencyView> pluginDependencies = null;
            Set<PluginDependencyView> impliedPluginDependencies = null;
            try {
                pluginDependencies = plugin.getLocalPluginDependencies();
                impliedPluginDependencies = plugin.getImpliedPluginDependencies();
            } catch (final GalleyMavenException e) {
                logger.error(String.format("%s: Cannot retrieve plugin dependencies for: %s. Reason: %s", projectRef, pluginRef, e.getMessage()), e);
            } catch (final InvalidVersionSpecificationException e) {
                logger.error(String.format("%s: Cannot retrieve plugin dependencies for: %s. Reason: %s", projectRef, pluginRef, e.getMessage()), e);
            } catch (final InvalidRefException e) {
                logger.error(String.format("%s: Cannot retrieve plugin dependencies for: %s. Reason: %s", projectRef, pluginRef, e.getMessage()), e);
            }
            addPluginDependencies(pluginDependencies, plugin, pluginRef, projectRef, builder, source, managed);
            logger.debug("{}: Adding implied dependencies for: {}\n\n  {}", projectRef, pluginRef, impliedPluginDependencies == null ? "-NONE-" : new JoinString("\n  ", impliedPluginDependencies));
            addPluginDependencies(impliedPluginDependencies, plugin, pluginRef, projectRef, builder, source, managed);
        }
    }
}
Also used : GalleyMavenException(org.commonjava.maven.galley.maven.GalleyMavenException) SimplePluginRelationship(org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship) InvalidRefException(org.commonjava.maven.atlas.ident.ref.InvalidRefException) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) URI(java.net.URI) PluginDependencyView(org.commonjava.maven.galley.maven.model.view.PluginDependencyView) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) InvalidVersionSpecificationException(org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) PluginView(org.commonjava.maven.galley.maven.model.view.PluginView)

Aggregations

URI (java.net.URI)1 SimplePluginRelationship (org.commonjava.maven.atlas.graph.rel.SimplePluginRelationship)1 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)1 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)1 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)1 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)1 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)1 PluginDependencyView (org.commonjava.maven.galley.maven.model.view.PluginDependencyView)1 PluginView (org.commonjava.maven.galley.maven.model.view.PluginView)1