You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jaikiran <ja...@yahoo.co.in> on 2008/12/21 10:22:30 UTC

Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

I am seeing an issue with the order in which the plugin execution happens
when there are multiple plugin associated with the same phase. I am using
Maven 2.0.9. As per the documentation, the order in which they should be
executed is the same as the order in which they are being defined in the
POM. However, i don't see this happening. Here's my (sample) POM:

<build>
   
   		<plugins>

		<!-- Do Step1 through Plugin ABC -->
		<plugin>
          		<groupId>something.something.ABC</groupId>
	            	<artifactId>ABCArtifact</artifactId>
        	    	<version>${someversionofABC}</version>
            	
            		<!-- Executions -->
            		<!-- 
                		Deploy the tutorial 
              		-->
            	
                	<executions>
              		   	<execution>
	        		        <id>Step1</id>
	                		<goals>
	                  			<goal>deploy</goal>
	                		</goals>
	                		<phase>install</phase>
	              		</execution>
				    
			

			</executions>

		</plugin>

		<!-- Do Step2 through Plugin XYZ -->
		<plugin>
        		<artifactId>maven-antrun-plugin</artifactId>
        		<executions>
        			<execution>
	          			<id>Step2</id>
					<phase>install</phase>
	            		<goals>
	              			<goal>run</goal>
	            		</goals>
			... // other stuff
			</execution>
		       </executions>
      		</plugin>
      		
      		<!--  Do Step3 from the same plugin ABC -->
      		
      		<plugin>
          		<groupId>something.something.ABC</groupId>
	            	<artifactId>ABCArtifact</artifactId>
        	    	<version>${someversionofABC}</version>
            	
	                <executions>
              		   	<execution>
	        		        <id>Step3</id>
	                		<goals>
	                  			<goal>undeploy</goal>
	                		</goals>
	                		<phase>install</phase>
	                		... // other stuff
	              		</execution>
			</executions>

		</plugin> 


As can be seen, the POM has 3 steps: Step1 Step2 and Step3 all bound to the
"install" phase. Step1 and Step3 use plugin ABC where as Step2 uses plugin
XYZ. Based on the POM ordering and the Maven documentation, the order of
execution is expected to be Step1 then Step2 and then Step3. However i am
consistently seeing the following incorrect order Step3 then Step1 and then
Step2. 

Am i missing something?      		
-- 
View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21113516.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jaikiran <ja...@yahoo.co.in>.

Jörg Schaible-2 wrote:
> 
> Basically I mean the possibility to turn a POM in some kind of Ant build
> script. Especially I refer the 3rd paragraph here:
> http://maven.apache.org/background/philosophy-of-maven.html. 
> ...
> Meanwhile I can also see here on the Maven list some kind of "we must
> support any cornercase" attitude, simply because some people do not want
> to
> follow Maven's best practices building their projects
> 
Jörg, i understand what you are saying. The only reason i ventured this
path, was because of the documentation which illustrated this kind of
ability with plugins. Again, i am not blaming anyone and i do understand
that the usecase i am trying is not something Maven supports. Fair enough
:-)

-- 
View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21156079.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jörg Schaible <jo...@gmx.de>.
Stephen Connolly wrote:

> 2008/12/23 Jaikiran <ja...@yahoo.co.in>
> 
>>
>>
>> Jörg Schaible-2 wrote:
>> >
>> > Well, personally I hope it will not change. Otherwise we will face a
>> > lot more Ant-like POMs which contradicts IMHO the original design goal.
>> >
>> > - Jörg
>> >
>>
>> I did not get this. Do you mean allowing the same plugin to be included
>> multiple times for the same phase won't be a good feature?
>>
> 
> Nope, what he means is multiple <plugin> sections for the same plugin....
> you should just use multiple <execution> sections in the one <plugin>
> section.

Basically I mean the possibility to turn a POM in some kind of Ant build
script. Especially I refer the 3rd paragraph here:
http://maven.apache.org/background/philosophy-of-maven.html. If you had
ever used a large project with a lot of developers using highly individual
Ant scripts, you know what I mean. A pure maintenance nightmare that
already starts not with the first line of code to fix, but with the initial
build.

Meanwhile I can also see here on the Maven list some kind of "we must
support any cornercase" attitude, simply because some people do not want to
follow Maven's best practices building their projects. If somebody really
has the need for a very individual process building an artifact it might be
better if he develops his own plugin doing the job at once instead of
cascading a whole bunch of different plugins multiple times. The result
will be that this complete build section is copied over again a multiple
time and then we're back to Ant times.

- Jörg

> 
> The only reason I can see for it changing is to allow using multiple
> versions of the same plugin... I would still think that you can only have
> one plugin section for each groupId:artifactId:version in any one plugins
> section...
> 
> For maven 2.0.x this is more strict in that you cannot differentiate by
> version due to Maven 2.0.x's class-loading of plugins (i.e. first version
> wins)
> 
> 
>>
>> --
>> View this message in context:
>>
http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21143702.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>



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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Stephen Connolly <st...@gmail.com>.
2008/12/23 Jaikiran <ja...@yahoo.co.in>

>
>
> Jörg Schaible-2 wrote:
> >
> > Well, personally I hope it will not change. Otherwise we will face a lot
> > more Ant-like POMs which contradicts IMHO the original design goal.
> >
> > - Jörg
> >
>
> I did not get this. Do you mean allowing the same plugin to be included
> multiple times for the same phase won't be a good feature?
>

Nope, what he means is multiple <plugin> sections for the same plugin....
you should just use multiple <execution> sections in the one <plugin>
section.

The only reason I can see for it changing is to allow using multiple
versions of the same plugin... I would still think that you can only have
one plugin section for each groupId:artifactId:version in any one plugins
section...

For maven 2.0.x this is more strict in that you cannot differentiate by
version due to Maven 2.0.x's class-loading of plugins (i.e. first version
wins)


>
> --
> View this message in context:
> http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21143702.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jaikiran <ja...@yahoo.co.in>.

Jörg Schaible-2 wrote:
> 
> Well, personally I hope it will not change. Otherwise we will face a lot
> more Ant-like POMs which contradicts IMHO the original design goal.
> 
> - Jörg
> 

I did not get this. Do you mean allowing the same plugin to be included
multiple times for the same phase won't be a good feature?

-- 
View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21143702.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jörg Schaible <jo...@gmx.de>.
Brett Porter wrote:

> This is a limitation of the way Maven currently specifies the
> executions. While it might be changed in the future it is currently by
> design.

Well, personally I hope it will not change. Otherwise we will face a lot
more Ant-like POMs which contradicts IMHO the original design goal.

- Jörg


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jaikiran <ja...@yahoo.co.in>.

brettporter wrote:
> 
> This is a limitation of the way Maven currently specifies the  
> executions. While it might be changed in the future it is currently by  
> design.
> 
I understand. Do you want me to raise a feature request?


brettporter wrote:
> 
> You seem to be using the "install" phase for a purpose it was not  
> designed for 
> 
I have to agree with that. But just for the benefit of others who are
reading this - the limitation is not just with the install phase.


brettporter wrote:
> 
>  I suggest moving these to a different location, using  
> standalone goals, or writing a custom mojo to perform the tasks in  
> sequence (Don's mojo-executor plugin can help).
> 

Thanks Brett, i will have a look.

-- 
View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21141720.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Brett Porter <br...@apache.org>.
This is a limitation of the way Maven currently specifies the  
executions. While it might be changed in the future it is currently by  
design.

You seem to be using the "install" phase for a purpose it was not  
designed for - I suggest moving these to a different location, using  
standalone goals, or writing a custom mojo to perform the tasks in  
sequence (Don's mojo-executor plugin can help).

- Brett

On 23/12/2008, at 1:50 AM, Jaikiran wrote:

>
> Merging the executions of the plugin, atleast in this case, is not  
> possible.
> Merging will make it:
>
>
>      	<plugin>
>            	<artifactId>ABCArtifact</artifactId>
>                <executions>
>              		   	<execution>
> 	        		        <id>Step1</id>
> 	                		<goals>
> 	                  			<goal>deploy</goal>
> 	                		</goals>
> 	                		<phase>install</phase>
> 	              		</execution>
>
> 				<execution>
> 	        		        <id>Step3</id>
> 	                		<goals>
> 	                  			<goal>undeploy</goal>
> 	                		</goals>
> 	                		<phase>install</phase>
> 	              		</execution>
> 			
> 		</executions>
>
> 	</plugin>
>
> So there will be no room for Step2 (which comes from a different  
> plugin).
> This was the original reason why i am repeating the same plugin  
> multiple
> times.
>
>
>
>
> John Stoneham wrote:
>>
>> On Mon, Dec 22, 2008 at 4:10 AM, Stephen Connolly
>> <st...@gmail.com> wrote:
>>> AFAIK, You cannot repeat the same plugin multiple times in the  
>>> plugins
>>> section.
>>>
>>> That is not to say that Maven should not support what you are  
>>> trying to
>>> do,
>>> just that my understanding of the rules of Maven for 2.0.x are  
>>> that you
>>> cannot do what you are trying to do using only one phase.
>>
>> Yes. You'd need to merge the executions section instead.
>>
>>
>> - John
>>
> -- 
> View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21129073.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jaikiran <ja...@yahoo.co.in>.
Merging the executions of the plugin, atleast in this case, is not possible.
Merging will make it:


      	<plugin>
            	<artifactId>ABCArtifact</artifactId>
                <executions>
              		   	<execution>
	        		        <id>Step1</id>
	                		<goals>
	                  			<goal>deploy</goal>
	                		</goals>
	                		<phase>install</phase>
	              		</execution>

				<execution>
	        		        <id>Step3</id>
	                		<goals>
	                  			<goal>undeploy</goal>
	                		</goals>
	                		<phase>install</phase>
	              		</execution>
			
		</executions>

	</plugin>

So there will be no room for Step2 (which comes from a different plugin).
This was the original reason why i am repeating the same plugin multiple
times.




John Stoneham wrote:
> 
> On Mon, Dec 22, 2008 at 4:10 AM, Stephen Connolly
> <st...@gmail.com> wrote:
>> AFAIK, You cannot repeat the same plugin multiple times in the plugins
>> section.
>>
>> That is not to say that Maven should not support what you are trying to
>> do,
>> just that my understanding of the rules of Maven for 2.0.x are that you
>> cannot do what you are trying to do using only one phase.
> 
> Yes. You'd need to merge the executions section instead.
> 
> 
> - John
> 
-- 
View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21129073.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by John Stoneham <ly...@lyrically.net>.
On Mon, Dec 22, 2008 at 4:10 AM, Stephen Connolly
<st...@gmail.com> wrote:
> AFAIK, You cannot repeat the same plugin multiple times in the plugins
> section.
>
> That is not to say that Maven should not support what you are trying to do,
> just that my understanding of the rules of Maven for 2.0.x are that you
> cannot do what you are trying to do using only one phase.

Yes. You'd need to merge the executions section instead.

(Of course if one execution is under a profile or something, they'll
be merged automatically.)

- John

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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Stephen Connolly <st...@gmail.com>.
Here is your pseudo-pom:

<build>

          <plugins>
               <plugin>
                       <groupId>something.something.ABC</groupId>
                       <artifactId>ABCArtifact</artifactId>
                       <version>${someversionofABC}</version>
               </plugin>
               <plugin>
                       <artifactId>maven-antrun-plugin</artifactId>
               </plugin>
               <plugin>
                       <groupId>something.something.ABC</groupId>
                       <artifactId>ABCArtifact</artifactId>
                       <version>${someversionofABC}</version>
               </plugin>

AFAIK, You cannot repeat the same plugin multiple times in the plugins
section.

That is not to say that Maven should not support what you are trying to do,
just that my understanding of the rules of Maven for 2.0.x are that you
cannot do what you are trying to do using only one phase.

-Stephen


2008/12/22 Jaikiran <ja...@yahoo.co.in>

>
> Thanks to Brett Porter, i found that this is similar to an already reported
> issue http://jira.codehaus.org/browse/MNG-3719
>
> I'll create a simple reproducible application and attach to that issue with
> more details. In the meantime, let me see if can i find a workaround for
> this issue.
> --
> View this message in context:
> http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21123663.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jaikiran <ja...@yahoo.co.in>.
Thanks to Brett Porter, i found that this is similar to an already reported
issue http://jira.codehaus.org/browse/MNG-3719

I'll create a simple reproducible application and attach to that issue with
more details. In the meantime, let me see if can i find a workaround for
this issue.
-- 
View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21123663.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Plugin execution order incorrect in Maven-2.0.9 when multiple plugins are associated with the same phase

Posted by Jaikiran <ja...@yahoo.co.in>.
No matter what i try, the ordering is not working. Let me know if i have to
report a JIRA with a sample application attached.


Jaikiran wrote:
> 
> I am seeing an issue with the order in which the plugin execution happens
> when there are multiple plugin associated with the same phase. I am using
> Maven 2.0.9. As per the documentation, the order in which they should be
> executed is the same as the order in which they are being defined in the
> POM. However, i don't see this happening. Here's my (sample) POM:
> 
> <build>
>    
>    		<plugins>
> 
> 		<!-- Do Step1 through Plugin ABC -->
> 		<plugin>
>           		<groupId>something.something.ABC</groupId>
> 	            	<artifactId>ABCArtifact</artifactId>
>         	    	<version>${someversionofABC}</version>
>             	
>             		<!-- Executions -->
>             		<!-- 
>                 		Deploy the tutorial 
>               		-->
>             	
>                 	<executions>
>               		   	<execution>
> 	        		        <id>Step1</id>
> 	                		<goals>
> 	                  			<goal>deploy</goal>
> 	                		</goals>
> 	                		<phase>install</phase>
> 	              		</execution>
> 				    
> 			
> 
> 			</executions>
> 
> 		</plugin>
> 
> 		<!-- Do Step2 through Plugin XYZ -->
> 		<plugin>
>         		<artifactId>maven-antrun-plugin</artifactId>
>         		<executions>
>         			<execution>
> 	          			<id>Step2</id>
> 					<phase>install</phase>
> 	            		<goals>
> 	              			<goal>run</goal>
> 	            		</goals>
> 			... // other stuff
> 			</execution>
> 		       </executions>
>       		</plugin>
>       		
>       		<!--  Do Step3 from the same plugin ABC -->
>       		
>       		<plugin>
>           		<groupId>something.something.ABC</groupId>
> 	            	<artifactId>ABCArtifact</artifactId>
>         	    	<version>${someversionofABC}</version>
>             	
> 	                <executions>
>               		   	<execution>
> 	        		        <id>Step3</id>
> 	                		<goals>
> 	                  			<goal>undeploy</goal>
> 	                		</goals>
> 	                		<phase>install</phase>
> 	                		... // other stuff
> 	              		</execution>
> 			</executions>
> 
> 		</plugin> 
> 
> 
> As can be seen, the POM has 3 steps: Step1 Step2 and Step3 all bound to
> the "install" phase. Step1 and Step3 use plugin ABC where as Step2 uses
> plugin XYZ. Based on the POM ordering and the Maven documentation, the
> order of execution is expected to be Step1 then Step2 and then Step3.
> However i am consistently seeing the following incorrect order Step3 then
> Step1 and then Step2. 
> 
> Am i missing something?      		
> 

-- 
View this message in context: http://www.nabble.com/Plugin-execution-order-incorrect-in-Maven-2.0.9-when-multiple-plugins-are-associated-with-the-same-phase-tp21113516p21123472.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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