On 19 January 2012 11:53, Julien Ruaux <[email protected]> wrote:
> Hi,
>
> I'm trying to get my plugin to automatically call another one (the
> JAXB XJC Maven plugin).
>
> Here is what users of my plugin currently have to write:
>
> <project>
> <build>
> <plugins>
> <plugin>
> <groupId>com.sun.tools.xjc.maven2</groupId>
> <artifactId>maven-jaxb-plugin</artifactId>
> <version>1.1.1</version>
> <executions>
> <execution>
> <goals>
> <goal>generate</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
>
> <schemaDirectory>Resources/Schemas</schemaDirectory>
> </configuration>
> </plugin>
> <plugin>
> <groupId>sample.plugin</groupId>
> <artifactId>my-maven-plugin</artifactId>
> <version>1.0-SNAPSHOT</version>
> <executions>
> <execution>
> <phase>process-classes</phase>
> <goals>
> <goal>generate</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
> <generate>...</generate>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
>
>
> This is what I would like my user's pom to look like :
>
> <project>
> <build>
> <plugins>
> <plugin>
> <groupId>sample.plugin</groupId>
> <artifactId>my-maven-plugin</artifactId>
> <version>1.0-SNAPSHOT</version>
> <configuration>
>
> <schemaDirectory>Resources/Schemas</schemaDirectory>
> <generate>...</generate>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
>
>
> Is that feasible?
No.
1. Unless you define a custom packaging, the default lifecycle is what
it is, and cannot be overridden, so you could do
<project>
...
<packaging>my-packaging</packaging>
...
<build>
<plugins>
<plugin>
<groupId>sample.plugin</groupId>
<artifactId>my-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<schemaDirectory>Resources/Schemas</schemaDirectory>
<generate>...</generate>
</configuration>
<extensions>true</extensions> <!-- need this -->
</plugin>
</plugins>
</build>
</project>
and that would bind both your plugin's execution and the other
plugin's execution to your packaging's lifecycle
An alternative would be to define your own lifecycle and execute it as
a pre-req'd forked lifecycle... you'd still need people to add an
<executions> to get your goal to execute, but that would be the only
<execution>... the down side is that this is in a forked lifecycle
>
> Thanks for your help,
> Julien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>