Example usage for org.apache.maven.repository.metadata MetadataResolutionRequest MetadataResolutionRequest

List of usage examples for org.apache.maven.repository.metadata MetadataResolutionRequest MetadataResolutionRequest

Introduction

In this page you can find the example usage for org.apache.maven.repository.metadata MetadataResolutionRequest MetadataResolutionRequest.

Prototype

public MetadataResolutionRequest(ArtifactMetadata query, ArtifactRepository localRepository,
            List<ArtifactRepository> remoteRepositories) 

Source Link

Usage

From source file:org.ebayopensource.turmeric.eclipse.mavenapi.impl.AbstractMavenApi.java

License:Open Source License

/**
 * Resolves the artifact Metadata from the repository.
 *
 * @param embedder the maven implementation to use
 * @param md the artifact metadata/*from   w  w w .  j  a  v a 2s . c  o m*/
 * @return the MetadataResolutionResult
 * @throws MavenEclipseApiException the maven eclipse api exception
 */
protected MetadataResolutionResult resolveArtifactMetadata(MavenImpl embedder, ArtifactMetadata md)
        throws MavenEclipseApiException {
    if (embedder == null)
        throw new MavenEclipseApiException("null embedder supplied");

    if (md == null)
        throw new MavenEclipseApiException("null metadata object supplied");

    try {
        List<ArtifactRepository> repos = _getKnownRepositories(embedder, md.getType());
        if (repos == null || repos.size() < 1) {
            throw new MavenEclipseApiException(Messages.ERROR_NO_REPOSITORIES);
        }

        //PlexusContainer plexus = embedder.getPlexusContainer();
        ArtifactRepository localRepository = MavenPlugin.getDefault().getMaven().getLocalRepository();
        List<ArtifactRepository> remoteRepositories = _getKnownRepositories(embedder, md.getType());

        MetadataResolutionRequest req = new MetadataResolutionRequest(md, localRepository, remoteRepositories);
        MetadataResolutionResult res = MavenApiUtil.resolveMetadata(MavenApiHelper.getRepositorySystem(), req);

        return res;

    } catch (Exception e) {
        e.printStackTrace();
        throw new MavenEclipseApiException(e);
    }
}