[ http://jira.codehaus.org/browse/MNG-1665?page=comments#action_61247 ] 

Mark J. Sinke commented on MNG-1665:
------------------------------------

Milos, I also sent you a mail on this, but this is probably useful to the 
community as well:

Here's a sample subclass of MavenEmbedder that replaces the 
DefaultArtifactResolver by a subclass of it (EclipseArtifactResolver extends 
DefaultArtifactResolver). We still want all of DefaultArtifactResolver's 
dependencies to be satisfied.

{quote}
/* $Id: org.eclipse.jdt.ui.prefs,v 1.1 2005/09/30 23:08:35 eu Exp $ */

package org.maven.ide.eclipse;

import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.embedder.MavenEmbedder;
import org.apache.maven.embedder.MavenEmbedderException;

import org.codehaus.plexus.embed.Embedder;

public class EclipseMavenEmbedder extends MavenEmbedder {
  protected void lookupComponents(Embedder embedder) throws 
MavenEmbedderException {
    // override the default ArtifactResolver with the Eclipse version
    +embedder.getContainer().getComponentDescriptor(ArtifactResolver.ROLE).+
        +setImplementation(EclipseArtifactResolver.class.getCanonicalName());+
    
    super.lookupComponents(embedder);
  }
}
{quote}

Of course, when you provide an entirely different resolver, you can implement 
ArtifactResolver directly.
In that case you'd use addComponentDescriptor() instead of 
getComponentDescriptor() and chaning the descriptor.

> allow changing plexus components implementations dynamically through embedder
> -----------------------------------------------------------------------------
>
>          Key: MNG-1665
>          URL: http://jira.codehaus.org/browse/MNG-1665
>      Project: Maven 2
>         Type: New Feature

>   Components: Embedding
>     Reporter: Milos Kleint
>  Attachments: custom-config.patch
>
>
> when running in the IDE one might have special requirements on Artifact 
> resolution, handling, output handling or any other aspect of the maven 
> environment.
> it would be nice to be able to replace the default implementations with 
> custom ones for that matter. The most natural place seems to be the embedder 
> class.
> example usecase.
> When resolving dependencies for a project (even transitively), I would like 
> 1. to know what deps were not resolved correctly, 2. avoid downloading the 
> dependencies at certain times.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to