Search in sources :

Example 6 with ArtifactRef

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

the class MavenModelProcessor method addDependencies.

private void addDependencies(final List<DependencyView> deps, final ProjectVersionRef projectRef, final Builder builder, final URI source, final boolean managed) {
    if (deps != null) {
        for (final DependencyView dep : deps) {
            try {
                final ProjectVersionRef ref = dep.asProjectVersionRef();
                final String profileId = dep.getProfileId();
                final URI location = RelationshipUtils.profileLocation(profileId);
                final ArtifactRef artifactRef = new SimpleArtifactRef(ref, dep.getType(), dep.getClassifier());
                // force the InvalidVersionSpecificationException.
                artifactRef.getVersionSpec();
                Set<ProjectRefView> exclusionsView = dep.getExclusions();
                ProjectRef[] excludes;
                if (exclusionsView != null && !exclusionsView.isEmpty()) {
                    excludes = new ProjectRef[exclusionsView.size()];
                    int i = 0;
                    for (ProjectRefView exclusionView : exclusionsView) {
                        excludes[i] = exclusionView.asProjectRef();
                        i++;
                    }
                } else {
                    excludes = new ProjectRef[0];
                }
                builder.withDependencies(new SimpleDependencyRelationship(source, location, projectRef, artifactRef, dep.getScope(), builder.getNextDependencyIndex(managed), managed, dep.getOriginInfo().isInherited(), dep.isOptional(), excludes));
            } catch (final InvalidRefException e) {
                logger.error(String.format("%s: dependency is invalid! Reason: %s. Skipping:\n\n%s\n\n", projectRef, e.getMessage(), dep.toXML()), e);
            } catch (final InvalidVersionSpecificationException e) {
                logger.error(String.format("%s: dependency is invalid! Reason: %s. Skipping:\n\n%s\n\n", projectRef, e.getMessage(), dep.toXML()), e);
            } catch (final GalleyMavenException e) {
                logger.error(String.format("%s: dependency is invalid! Reason: %s. Skipping:\n\n%s\n\n", projectRef, e.getMessage(), dep.toXML()), e);
            }
        }
    }
}
Also used : GalleyMavenException(org.commonjava.maven.galley.maven.GalleyMavenException) ProjectRefView(org.commonjava.maven.galley.maven.model.view.ProjectRefView) InvalidRefException(org.commonjava.maven.atlas.ident.ref.InvalidRefException) SimpleArtifactRef(org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) PluginDependencyView(org.commonjava.maven.galley.maven.model.view.PluginDependencyView) DependencyView(org.commonjava.maven.galley.maven.model.view.DependencyView) URI(java.net.URI) ArtifactRef(org.commonjava.maven.atlas.ident.ref.ArtifactRef) SimpleArtifactRef(org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef) InvalidVersionSpecificationException(org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleDependencyRelationship(org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship) ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef)

Example 7 with ArtifactRef

use of org.commonjava.maven.atlas.ident.ref.ArtifactRef in project indy by Commonjava.

the class KojiContentManagerDecorator method findKojiBuildAnd.

private <T> T findKojiBuildAnd(ArtifactStore store, String path, EventMetadata eventMetadata, T defValue, KojiBuildAction<T> action) throws IndyWorkflowException {
    if (!config.getEnabled()) {
        Logger logger = LoggerFactory.getLogger(getClass());
        logger.info("Koji content-manager decorator is disabled.");
        return defValue;
    }
    Group group = (Group) store;
    if (!config.isEnabledFor(group.getName())) {
        Logger logger = LoggerFactory.getLogger(getClass());
        logger.info("Koji content-manager decorator not enabled for: {}.", store.getKey());
        return defValue;
    }
    Logger logger = LoggerFactory.getLogger(getClass());
    // TODO: This won't work for maven-metadata.xml files! We need to hit a POM or jar or something first.
    ArtifactPathInfo pathInfo = ArtifactPathInfo.parse(path);
    if (pathInfo != null) {
        ArtifactRef artifactRef = pathInfo.getArtifact();
        logger.info("Searching for Koji build: {}", artifactRef);
        return proxyKojiBuild(store.getKey(), artifactRef, path, eventMetadata, defValue, action);
    } else {
        logger.info("Path is not a maven artifact reference: {}", path);
    }
    return defValue;
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactPathInfo(org.commonjava.maven.atlas.ident.util.ArtifactPathInfo) Logger(org.slf4j.Logger) ArtifactRef(org.commonjava.maven.atlas.ident.ref.ArtifactRef)

Aggregations

ArtifactRef (org.commonjava.maven.atlas.ident.ref.ArtifactRef)7 URI (java.net.URI)3 SimpleArtifactRef (org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef)3 Transfer (org.commonjava.maven.galley.model.Transfer)3 ArrayList (java.util.ArrayList)2 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)2 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)2 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)2 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)2 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)2 PluginDependencyView (org.commonjava.maven.galley.maven.model.view.PluginDependencyView)2 Location (org.commonjava.maven.galley.model.Location)2 Logger (org.slf4j.Logger)2 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)1 Group (org.commonjava.indy.model.core.Group)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 SimpleDependencyRelationship (org.commonjava.maven.atlas.graph.rel.SimpleDependencyRelationship)1