You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Julien Ruaux <jr...@gmail.com> on 2012/01/19 12:53:08 UTC

plugin dependency

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?

Thanks for your help,
Julien

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


Re: plugin dependency

Posted by Stephen Connolly <st...@gmail.com>.
On 19 January 2012 11:53, Julien Ruaux <jr...@gmail.com> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>