Hi

Did you try writing an extension instead of a mojo? It does exactly that (+
few other things)

Le 18 déc. 2017 19:03, "Quijada, Jose M" <jose.quij...@verizon.com> a
écrit :

> I would like to write a Maven plugin that among other things manipulates
> (both add/update) the POM model available at MavenProjects.getModel() while
> executing Maven phase goals, such as "test" and "site", so that for
> instance I can:
>
> 1) Add a <reporting/> node along with plugins inside, so that when the
> "site" phase runs, those plugins can be used to generate reports
> 2) On the fly add plugins to <build/>, along with <executions/> for those
> plugins, so that they run as part of other phases.
> 3) Fro plugins that are already in the POM model, update things like
> versions, <executions/>.
>
>
> I already wrote the plugin, and wrote Java code to make the necessary
> additions/update to the POM. I've injected MavenProject into my Mojo via
> @Parameter(defaultValue = "${project}")
>
> private MavenProject project;
>
>
> But those additions/changes to the POM Model object are being ignored.
> For exaxample,
>
> one use case I have is to tack on <reporting/> with a bunch of plugins
>
> and reports they should generate. I execute my custom logic as part of
>
> the pre-site face (I create a Mojo and configured its goal to run with
> pre-site). Then n
>
> in the code of the Mojo I do the additions/updates to the POM. But
> when "site" phase runs,
>
> the reports added to the POM not executing.
>
>
> Am I missing something fundamental about Maven POM? Are modifications
> to POM at runtime
>
> not allowed? I suspect this is the reason, but I wanted to confirmed with
>
> more experienced Maven developers.
>
>
> Thank you, and let me know what other details I can provide to clarify
> things.
>
>
>
> Best,
>
> Jose.
>

Reply via email to