to extend non-local plugins where the source is not available...Take a look at implementing maven-inherit-plugin
http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin HTH Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Thu, 9 Aug 2012 12:29:44 +0200 > Subject: Re: MavenProject/MavenSession not injected when executing plugin > from a plugin > From: [email protected] > To: [email protected] > > Hi > Have a look at how we solve that in the site plugin sources > That will probably help you. > > -- > Olivier > Le 9 août 2012 09:29, "Kinai User" <[email protected]> a écrit : > > > Hi there, > > > > I have developed a plugin which can execute other Maven plugins depending > > on > > certain properties available in a project. > > > > The process is like this: > > 1. Maven build starts > > 2. Plugin A is triggered which has several executions defined. Depending on > > properties in the project on hand a execution is triggered > > 3. Plugin B (or C, D etc) will be triggered. > > > > The problem is I do not have access to the MavenProject and MavenSession in > > Plugin B (or C, D) because these are not injected resulting in > > NullPointerExceptions. The BuildPluginManager however is correctly injected > > (however not needed in this plugin but added it to test the mechanism). > > > > I'm using the same syntax in Plugin A and there both MavenProject and > > MavenSession are injected. > > > > Some code examples: > > > > Plugin A executing other plugins: > > ---------------------------------------- > > private void executePlugin ( Plugin plugin, String executionId, String > > goal ) throws MojoExecutionException > > { > > try > > { > > List<RemoteRepository> repositories = > > session.getCurrentProject().getRemoteProjectRepositories(); > > > > MojoDescriptor mojoDescriptor = > > pluginManager.getMojoDescriptor(plugin, goal, repositories, > > session.getRepositorySession()); > > MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, > > executionId ); > > getLog().info( "Executing goal " + goal + " within execution " + > > executionId + " for plugin " + plugin ); > > pluginManager.executeMojo(session , mojoExecution); > > } > > catch ( Exception e ) > > { > > throw new MojoExecutionException( "Error executing plugin " + > > plugin + " with execution id " + > > executionId, e ); > > } > > } > > > > > > Plugin B > > ---------------- > > /** > > * Goal which updates the VersionIF.java with the current version. > > * @goal updateVersion > > * @phase process-sources > > * > > */ > > > > public class VersionIFMojo extends AbstractMojo { > > > > /** > > * The Maven project. > > * > > * @parameter expression="${project}" > > */ > > private MavenProject project; > > > > /** > > * The Maven Session Object > > * > > * @parameter expression="${session}" > > * @readonly > > */ > > protected MavenSession session; > > > > /** > > * Plugin manager used to invoke plugin executions. > > * > > * @required > > * @component > > */ > > private BuildPluginManager pManager; > > > > <...> > > > > All worked well when using Maven 2 but after migrating to Maven 3 builds > > stopped working. > > Can somebody help me resolving this issue? > > > > Thank you > > > > Kind regards, > > Richad > > > > > > > > -- > > View this message in context: > > http://maven.40175.n5.nabble.com/MavenProject-MavenSession-not-injected-when-executing-plugin-from-a-plugin-tp5716570.html > > Sent from the Maven - Users mailing list archive at Nabble.com. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > >
