Aaron Novstrup
Aaron Novstrup

Reputation: 21017

Can Maven 2 use two different versions of a build plugin in the same project?

My project requires features of a new version of a maven build plugin for some of its goals, but the new version fails (due to a bug in the plugin) on one of the other goals. As a workaround until the bug is fixed, I'd like to run the broken goal with an older version of the plugin. Edit: More specifically, I need to run the generateAsync goal with version 1.1 of the gwt-maven-plugin and all other goals with version 1.2-SNAPSHOT.

When I declare a separate plugin version to execute the broken goal, Maven still uses the broken version. Is there another way to solve this problem?

<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>gwt-maven-plugin</artifactId>
 <version>1.1</version>
   <executions>
     <execution>
       <goals>
         <!-- this goal is broken in 1.2-SNAPSHOT -->
         <goal>generateAsync</goal>
       </goals>
     </execution>
   </executions>
   ...
 </plugin>
 <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>gwt-maven-plugin</artifactId>
   <version>1.2-SNAPSHOT</version>
   <executions>
     <execution>
       <goals>
         <goal>compile</goal>
         <!-- <goal>generateAsync</goal> -->
         <goal>test</goal>
       </goals>
     </execution>
   </executions>
   ...
</plugin>

Upvotes: 6

Views: 2210

Answers (2)

Pascal Thivent
Pascal Thivent

Reputation: 570545

You must not declare the same plugin twice in your POM. What is possible is to use one <plugin> block with two <executions> but this won't solve your issue so, no, there is no way to achieve what you want.

But did you test the gwt-maven-plugin 1.2 release candidate? It has been made available today here http://people.apache.org/~nicolas/staging/, vote is open for 72h and tests are welcome. Maybe your issue is solved in this version (not sure though as you didn't give much details on the problem and as I didn't find any issue related to gwt:generateAsync in the issue tracker of the plugin that has been recently closed or opened).

If you have a particular problem not listed in the issue tracker, it seems to be the perfect time to make people aware of it, especially if you want it solved in version 1.2. The ball is in your court.

Upvotes: 4

Hugo Palma
Hugo Palma

Reputation: 3566

I think that what your looking for is the phase element on the plugin configuration. The goal element indicates which goal of the plugin you want to execute, the phase does what you want which is to indicate in which phase should the goal of the plugin be executed.

You can see more about this here.

Upvotes: 0

Related Questions