Discussion:
How to execute multiple goals via a single command ?
Nick Pellow
2008-09-16 09:03:10 UTC
Permalink
Hi,

I have 3 MOJOs in a single maven plugin. Each MOJO needs to be
executed during specific build phases.
What is the best way to make this possible, without forcing users of
the plugin to insert explicit executions into their pom.xml ?

i.e. is it possible to make the following configuration by doing it
programitcally in the plugin itself?
<executions>
<execution>
<id>1</id>
<phase>process-sources</phase>
<goals>
<goal>first</goal>
</goals>
</execution>
<execution>
<id>2</id>
<phase>process-test-classes</phase>
<goals>
<goal>second</goal>
</goals>
</execution>
<execution>
<id>3</id>
<phase>test</phase>
<goals>
<goal>third</goal>
</goals>
</execution>
</executions>

this will result in: process-sources plugin:first process-test-classes
plugin:second test plugin:third
being run whenever the test phase is called.

I have used the @phase <phaseName> annotation in each MOJO. These seem
to get ignored however if the goal is not called directly?

Please let me know if you require further information regarding this.

Cheers,
Nick
Nick Stolwijk
2008-09-16 09:15:39 UTC
Permalink
As far as I know you have to specify the goals in your projects, which
uses your plugin. If you have the right @phase annotations it should
be enough to add only the executions like so:

<executions>
<execution>
<goals>
<goal>one</goal>
<goal>two</goal>
<goal>three</goal>
</goals>
</execution>
</executions>

As far as I know it is not possible to automatically add the goals to
the life cycle without specifying its execution.

Hth,

Nick Stolwijk
~Java Developer~

Iprofs BV.
Claus Sluterweg 125
2012 WS Haarlem
www.iprofs.nl
Hi,
I have 3 MOJOs in a single maven plugin. Each MOJO needs to be executed
during specific build phases.
What is the best way to make this possible, without forcing users of the
plugin to insert explicit executions into their pom.xml ?
i.e. is it possible to make the following configuration by doing it
programitcally in the plugin itself?
<executions>
<execution>
<id>1</id>
<phase>process-sources</phase>
<goals>
<goal>first</goal>
</goals>
</execution>
<execution>
<id>2</id>
<phase>process-test-classes</phase>
<goals>
<goal>second</goal>
</goals>
</execution>
<execution>
<id>3</id>
<phase>test</phase>
<goals>
<goal>third</goal>
</goals>
</execution>
</executions>
this will result in: process-sources plugin:first process-test-classes
plugin:second test plugin:third
being run whenever the test phase is called.
get ignored however if the goal is not called directly?
Please let me know if you require further information regarding this.
Cheers,
Nick
Stephen Connolly
2008-09-16 09:34:12 UTC
Permalink
You could have your plugin define a custom packaging and then bind the
plugin goals to phases for that custom packaging's lifecycle.

Otherwise I think you're low on luck
Post by Nick Stolwijk
As far as I know you have to specify the goals in your projects, which
<executions>
<execution>
<goals>
<goal>one</goal>
<goal>two</goal>
<goal>three</goal>
</goals>
</execution>
</executions>
As far as I know it is not possible to automatically add the goals to
the life cycle without specifying its execution.
Hth,
Nick Stolwijk
~Java Developer~
Iprofs BV.
Claus Sluterweg 125
2012 WS Haarlem
www.iprofs.nl
Hi,
I have 3 MOJOs in a single maven plugin. Each MOJO needs to be executed
during specific build phases.
What is the best way to make this possible, without forcing users of the
plugin to insert explicit executions into their pom.xml ?
i.e. is it possible to make the following configuration by doing it
programitcally in the plugin itself?
<executions>
<execution>
<id>1</id>
<phase>process-sources</phase>
<goals>
<goal>first</goal>
</goals>
</execution>
<execution>
<id>2</id>
<phase>process-test-classes</phase>
<goals>
<goal>second</goal>
</goals>
</execution>
<execution>
<id>3</id>
<phase>test</phase>
<goals>
<goal>third</goal>
</goals>
</execution>
</executions>
this will result in: process-sources plugin:first process-test-classes
plugin:second test plugin:third
being run whenever the test phase is called.
get ignored however if the goal is not called directly?
Please let me know if you require further information regarding this.
Cheers,
Nick
---------------------------------------------------------------------
Nick Pellow
2008-09-16 11:36:33 UTC
Permalink
Hi Nick,

Thanks for this suggestion. I tested this and it works.
It will certainly help reduce the XML bloat for now.

Cheers,
Nick
Post by Nick Stolwijk
As far as I know you have to specify the goals in your projects, which
<executions>
<execution>
<goals>
<goal>one</goal>
<goal>two</goal>
<goal>three</goal>
</goals>
</execution>
</executions>
As far as I know it is not possible to automatically add the goals to
the life cycle without specifying its execution.
Hth,
Nick Stolwijk
~Java Developer~
Iprofs BV.
Claus Sluterweg 125
2012 WS Haarlem
www.iprofs.nl
On Tue, Sep 16, 2008 at 11:03 AM, Nick Pellow
Hi,
I have 3 MOJOs in a single maven plugin. Each MOJO needs to be executed
during specific build phases.
What is the best way to make this possible, without forcing users of the
plugin to insert explicit executions into their pom.xml ?
i.e. is it possible to make the following configuration by doing it
programitcally in the plugin itself?
<executions>
<execution>
<id>1</id>
<phase>process-sources</phase>
<goals>
<goal>first</goal>
</goals>
</execution>
<execution>
<id>2</id>
<phase>process-test-classes</phase>
<goals>
<goal>second</goal>
</goals>
</execution>
<execution>
<id>3</id>
<phase>test</phase>
<goals>
<goal>third</goal>
</goals>
</execution>
</executions>
this will result in: process-sources plugin:first process-test-
classes
plugin:second test plugin:third
being run whenever the test phase is called.
get ignored however if the goal is not called directly?
Please let me know if you require further information regarding this.
Cheers,
Nick
---------------------------------------------------------------------
Continue reading on narkive:
Loading...