Search in sources :

Example 6 with InvalidRefException

use of org.commonjava.maven.atlas.ident.ref.InvalidRefException in project galley by Commonjava.

the class MavenModelProcessor method addExtensionUsages.

private void addExtensionUsages(final URI source, final Builder builder, final MavenPomView pomView, final ProjectVersionRef projectRef) throws GalleyMavenException {
    List<ExtensionView> extensions = null;
    try {
        extensions = pomView.getBuildExtensions();
    } catch (final GalleyMavenException e) {
        logger.error(String.format("%s: Cannot retrieve build extensions: %s", pomView.getRef(), e.getMessage()), e);
    } catch (final InvalidVersionSpecificationException e) {
        logger.error(String.format("%s: Cannot retrieve build extensions: %s", pomView.getRef(), e.getMessage()), e);
    } catch (final InvalidRefException e) {
        logger.error(String.format("%s: Cannot retrieve build extensions: %s", pomView.getRef(), e.getMessage()), e);
    }
    for (final ExtensionView ext : extensions) {
        if (ext == null) {
            continue;
        }
        try {
            final ProjectVersionRef ref = ext.asProjectVersionRef();
            // force the InvalidVersionSpecificationException.
            ref.getVersionSpec();
            builder.withExtensions(new SimpleExtensionRelationship(source, projectRef, ref, builder.getNextExtensionIndex(), ext.getOriginInfo().isInherited()));
        } catch (final InvalidRefException e) {
            logger.error(String.format("%s: Build extension is invalid! Reason: %s. Skipping:\n\n%s\n\n", pomView.getRef(), e.getMessage(), ext.toXML()), e);
        } catch (final InvalidVersionSpecificationException e) {
            logger.error(String.format("%s: Build extension is invalid! Reason: %s. Skipping:\n\n%s\n\n", pomView.getRef(), e.getMessage(), ext.toXML()), e);
        } catch (final GalleyMavenException e) {
            logger.error(String.format("%s: Build extension is invalid! Reason: %s. Skipping:\n\n%s\n\n", pomView.getRef(), e.getMessage(), ext.toXML()), e);
        }
    }
}
Also used : 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) SimpleExtensionRelationship(org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship) ExtensionView(org.commonjava.maven.galley.maven.model.view.ExtensionView)

Example 7 with InvalidRefException

use of org.commonjava.maven.atlas.ident.ref.InvalidRefException 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

InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)7 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)7 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)6 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)5 PluginDependencyView (org.commonjava.maven.galley.maven.model.view.PluginDependencyView)4 URI (java.net.URI)3 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)2 KojiClient (com.redhat.red.build.koji.KojiClient)1 KojiClientException (com.redhat.red.build.koji.KojiClientException)1 KojiArchiveInfo (com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo)1 KojiBuildArchiveCollection (com.redhat.red.build.koji.model.xmlrpc.KojiBuildArchiveCollection)1 KojiBuildInfo (com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo)1 KojiBuildState (com.redhat.red.build.koji.model.xmlrpc.KojiBuildState)1 KojiTagInfo (com.redhat.red.build.koji.model.xmlrpc.KojiTagInfo)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 Date (java.util.Date)1