maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JF <jfran...@his.co.uk>
Subject Writing a component for a Maven Plugin
Date Wed, 23 Nov 2011 09:49:04 GMT
I wish to write a component to inject into my Maven Mojo whichis running 
from an 'embedded' Maven deployment.
By embedded I mean I am starting up Plexus and Maven like this...


import org.apache.maven.Maven;
import org.apache.maven.cli.MavenLoggerManager;
import org.apache.maven.model.building.ModelProcessor;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.ClassWorld;
import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;

public class MvnServer2
{
     final Logger logger;
     final BespokeExecutionListener executionListener;
     final Maven maven;
     final ModelProcessor modelProcessor;


     MvnServer2() throws PlexusContainerException, 
ComponentLookupException {
         ClassWorld classWorld = new ClassWorld("plexus.core",
                                                
Thread.currentThread().getContextClassLoader());
         DefaultContainerConfiguration cc =
             new DefaultContainerConfiguration();
         cc.setClassWorld(classWorld);
         cc.setName("embedder");

         DefaultPlexusContainer plexus = new DefaultPlexusContainer(cc);
         logger = new ConsoleLogger();
         plexus.setLoggerManager(new MavenLoggerManager(logger));

         maven = plexus.lookup(Maven.class);
         modelProcessor = plexus.lookup(ModelProcessor.class);

         executionListener = new BespokeExecutionListener(logger);



I was looking at 
http://www.sonatype.com/people/2009/05/plexus-container-five-minute-tutorial/ 
but noticed that the archetypes and documentation at 
http://plexus.codehaus.org/guides/writing-components/00_index.html seems 
to be out of date. I also see that sonatype are migrating to Guice.
Which would be a better place to start for component writing, Guice or 
Plexus?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message