Search in sources :

Example 1 with ExtensionView

use of org.commonjava.maven.galley.maven.model.view.ExtensionView 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)

Aggregations

SimpleExtensionRelationship (org.commonjava.maven.atlas.graph.rel.SimpleExtensionRelationship)1 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)1 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)1 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)1 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)1 ExtensionView (org.commonjava.maven.galley.maven.model.view.ExtensionView)1