Search in sources :

Example 16 with GalleyMavenException

use of org.commonjava.maven.galley.maven.GalleyMavenException in project galley by Commonjava.

the class MavenModelProcessor method readRelationships.

public EProjectDirectRelationships readRelationships(final MavenPomView pomView, final URI source, final ModelProcessorConfig discoveryConfig) throws GalleyMavenException {
    final boolean includeManagedDependencies = discoveryConfig.isIncludeManagedDependencies();
    final boolean includeBuildSection = discoveryConfig.isIncludeBuildSection();
    final boolean includeManagedPlugins = discoveryConfig.isIncludeManagedPlugins();
    logger.info("Reading relationships for: {}\n  (from: {})", pomView.getRef(), source);
    try {
        final ProjectVersionRef projectRef = pomView.getRef();
        final EProjectDirectRelationships.Builder builder = new EProjectDirectRelationships.Builder(source, projectRef);
        addParentRelationship(source, builder, pomView, projectRef);
        addDependencyRelationships(source, builder, pomView, projectRef, includeManagedDependencies);
        if (includeBuildSection) {
            addExtensionUsages(source, builder, pomView, projectRef);
            addPluginUsages(source, builder, pomView, projectRef, includeManagedPlugins);
        }
        return builder.build();
    } catch (final InvalidVersionSpecificationException e) {
        throw new GalleyMavenException("Failed to parse version for model: {}. Reason: {}", e, pomView, e.getMessage());
    } catch (final IllegalArgumentException e) {
        throw new GalleyMavenException("Failed to parse relationships for model: {}. Reason: {}", e, pomView, e.getMessage());
    }
}
Also used : Builder(org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships.Builder) GalleyMavenException(org.commonjava.maven.galley.maven.GalleyMavenException) InvalidVersionSpecificationException(org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) Builder(org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships.Builder) EProjectDirectRelationships(org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships)

Example 17 with GalleyMavenException

use of org.commonjava.maven.galley.maven.GalleyMavenException in project indy by Commonjava.

the class ImpliedRepositoryDetector method initJob.

private boolean initJob(final ImplicationsJob job) {
    switch(job.event.getType()) {
        case DOWNLOAD:
        case UPLOAD:
            break;
        default:
            // we're not interested in these.
            return false;
    }
    final Transfer transfer = job.transfer;
    if (!transfer.getPath().endsWith(".pom")) {
        return false;
    }
    final Location location = transfer.getLocation();
    if (!(location instanceof KeyedLocation)) {
        return false;
    }
    final StoreKey key = ((KeyedLocation) location).getKey();
    try {
        job.store = storeManager.getArtifactStore(key);
    } catch (final IndyDataException e) {
        logger.error(String.format("Cannot retrieve artifact store for: %s. Failed to process implied repositories.", key), e);
    }
    if (job.store == null) {
        return false;
    }
    job.pathInfo = ArtifactPathInfo.parse(transfer.getPath());
    if (job.pathInfo == null) {
        return false;
    }
    try {
        logger.debug("Parsing: {}", transfer);
        job.pomView = pomReader.readLocalPom(job.pathInfo.getProjectId(), transfer, MavenPomView.ALL_PROFILES);
    } catch (final GalleyMavenException e) {
        logger.error(String.format("Cannot parse: %s from: %s. Failed to process implied repositories.", job.pathInfo.getProjectId(), transfer), e);
    }
    return job.pomView != null;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) GalleyMavenException(org.commonjava.maven.galley.maven.GalleyMavenException) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) Transfer(org.commonjava.maven.galley.model.Transfer) StoreKey(org.commonjava.indy.model.core.StoreKey) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) Location(org.commonjava.maven.galley.model.Location)

Aggregations

GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)17 InvalidVersionSpecificationException (org.commonjava.maven.atlas.ident.version.InvalidVersionSpecificationException)10 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)9 ArrayList (java.util.ArrayList)8 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)7 InvalidRefException (org.commonjava.maven.atlas.ident.ref.InvalidRefException)6 Location (org.commonjava.maven.galley.model.Location)6 MavenMetadataView (org.commonjava.maven.galley.maven.model.view.meta.MavenMetadataView)5 TreeMap (java.util.TreeMap)4 SingleVersion (org.commonjava.maven.atlas.ident.version.SingleVersion)4 TransferException (org.commonjava.maven.galley.TransferException)4 ProjectVersionRefLocation (org.commonjava.maven.galley.maven.model.ProjectVersionRefLocation)4 DocRef (org.commonjava.maven.galley.maven.model.view.DocRef)4 PluginDependencyView (org.commonjava.maven.galley.maven.model.view.PluginDependencyView)4 URI (java.net.URI)3 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)3 MavenPomView (org.commonjava.maven.galley.maven.model.view.MavenPomView)3 ArtifactRef (org.commonjava.maven.atlas.ident.ref.ArtifactRef)2 ProjectRef (org.commonjava.maven.atlas.ident.ref.ProjectRef)2 SimpleArtifactRef (org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef)2