You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lóránt Pintér <lo...@gmail.com> on 2010/01/28 10:32:28 UTC

Plugin executions vs. POM inheritance

Hi,

I'm using the dependency plugin a lot to copy stuff around (mostly to
get around the assembly plugin not allowing me to add arbitrary
artifacts to assemblies). Some uses are general, and are needed in
more than one module. AFAIK I should define these "general" executions
in a parent POM, under the <pluginManagement> section, and "call" them
from the actual modules by just specifying their execution ID, like:

<plugin>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
		<execution>
			<id>unpack-all-swt</id>
		</execution>
		<execution>
			<id>unpack-all-native</id>
		</execution>
	</executions>
</plugin>

However, the thing above does not only execute the "unpack-all-swt"
and "unpack-all-native" executions, but all other executions defined
in the parent POM. This also applies if I don't refer to executions
defined in parent at all, but define a new dependency plugin execution
in the child module.

It seems to me that if I "mention" a plugin in a child module, I get
all its executions defined in <pluginManagement> in the parent as
well. Is this as designed?

If this is the way it should work, is there a way to achieve what I
want? I.e. define some utility executions in parent that can be called
in child modules, but independent of other executions.

-- 
Regards,
Lóránt

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


Re: Plugin executions vs. POM inheritance

Posted by Alexander <th...@gmail.com>.
You could insert this utility executions in profile. e.g.

<profiles>
        <profile>
            <id>whatever</id>
            <build>
                <plugins>
                    <plugin>
                        ...
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

And this plugin will be executed only when this profile is activated.

2010/1/30 Lóránt Pintér <lo...@gmail.com>

> How could this be achieved with profiles?
>
> Lóránt
>
> On Fri, Jan 29, 2010 at 21:13, Wayne Fay <wa...@gmail.com> wrote:
> >> If this is the way it should work, is there a way to achieve what I
> >> want? I.e. define some utility executions in parent that can be called
> >> in child modules, but independent of other executions.
> >
> > Did you consider profiles for this purpose?
> >
> > Wayne
> >
> > ---------------------------------------------------------------------
> > 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
>
>


-- 
Regards,
Alexander

Re: Plugin executions vs. POM inheritance

Posted by Lóránt Pintér <lo...@gmail.com>.
How could this be achieved with profiles?

Lóránt

On Fri, Jan 29, 2010 at 21:13, Wayne Fay <wa...@gmail.com> wrote:
>> If this is the way it should work, is there a way to achieve what I
>> want? I.e. define some utility executions in parent that can be called
>> in child modules, but independent of other executions.
>
> Did you consider profiles for this purpose?
>
> Wayne
>
> ---------------------------------------------------------------------
> 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 executions vs. POM inheritance

Posted by Wayne Fay <wa...@gmail.com>.
> If this is the way it should work, is there a way to achieve what I
> want? I.e. define some utility executions in parent that can be called
> in child modules, but independent of other executions.

Did you consider profiles for this purpose?

Wayne

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


Re: Plugin executions vs. POM inheritance

Posted by Lóránt Pintér <lo...@gmail.com>.
Thanks, this works with the dependency plugin now. But I cannot get it
working with the assembly plugin. I do the same, though: add
<inherited>false</inherited> to the execution in the parent, and only
add the ID of this execution in the child module. What am I still
doing wrong?

Lóránt

On Thu, Jan 28, 2010 at 13:50, Stephen Connolly
<st...@gmail.com> wrote:
> <inherited>false</inherited>
>
> 2010/1/28 Lóránt Pintér <lo...@gmail.com>
>
>> Hi,
>>
>> I'm using the dependency plugin a lot to copy stuff around (mostly to
>> get around the assembly plugin not allowing me to add arbitrary
>> artifacts to assemblies). Some uses are general, and are needed in
>> more than one module. AFAIK I should define these "general" executions
>> in a parent POM, under the <pluginManagement> section, and "call" them
>> from the actual modules by just specifying their execution ID, like:
>>
>> <plugin>
>>        <artifactId>maven-dependency-plugin</artifactId>
>>        <executions>
>>                <execution>
>>                        <id>unpack-all-swt</id>
>>                </execution>
>>                <execution>
>>                        <id>unpack-all-native</id>
>>                </execution>
>>        </executions>
>> </plugin>
>>
>> However, the thing above does not only execute the "unpack-all-swt"
>> and "unpack-all-native" executions, but all other executions defined
>> in the parent POM. This also applies if I don't refer to executions
>> defined in parent at all, but define a new dependency plugin execution
>> in the child module.
>>
>> It seems to me that if I "mention" a plugin in a child module, I get
>> all its executions defined in <pluginManagement> in the parent as
>> well. Is this as designed?
>>
>> If this is the way it should work, is there a way to achieve what I
>> want? I.e. define some utility executions in parent that can be called
>> in child modules, but independent of other executions.
>>
>> --
>> Regards,
>> Lóránt
>>
>> ---------------------------------------------------------------------
>> 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 executions vs. POM inheritance

Posted by Andreas Sewe <se...@st.informatik.tu-darmstadt.de>.
Thanks Wayne, thanks Ron,

that looks like an alternative way to achieve what I want:
>> I am not sure what you are trying to do but I am wondering if you can build
>> several parent POMs and set up each POM have the parent that suits its
>> needs.
>
> Yes, this is the composition vs inheritance approach to managing your
> projects and poms. It can be useful in certain projects where eg the
> wars all have one war-parent, etc.

I am still curious, though, what Stephen meant by his reply to Lóránt's 
original question. From what I could gather, Lóránt is in a situation 
similar to myself, but <inherited>false</inherited> doesn't work for me 
at all.

What am I missing? (Neither the POM Reference nor the "Guide to 
Configuring Plug-ins" were of any help here.)

Best wishes,

Andreas

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


Re: Plugin executions vs. POM inheritance

Posted by Wayne Fay <wa...@gmail.com>.
> I am not sure what you are trying to do but I am wondering if you can build
> several parent POMs and set up each POM have the parent that suits its
> needs.

Yes, this is the composition vs inheritance approach to managing your
projects and poms. It can be useful in certain projects where eg the
wars all have one war-parent, etc.

Wayne

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


Re: Plugin executions vs. POM inheritance

Posted by Ron Wheeler <rw...@artifact-software.com>.
I am not sure what you are trying to do but I am wondering if you can 
build several parent POMs and set up each POM have the parent that suits 
its needs.

I am not sure how many combinations you need but AFAIK there is no need 
for each child to have the same parent.

Ron

Andreas Sewe wrote:
> Hi Stephen,
>
> I am in a situation similar to the OP's, so your reply made me 
> refactor my POMs. (Its never to late to get rid of a little 
> copy-n-paste :-)
>
> But unfortunately I couldn't get your proposal to work. Here's the 
> execution I configured in my parent POM, which I want to reuse in 
> *some* of my child POMs:
>
> <pluginManagement>
> <plugins>
> <plugin>
> <artifactId>maven-failsafe-plugin</artifactId>
> <version>2.5</version>
> <!-- Thrown in for good measure; I suspect I only need the 
> execution-level inherited -->
> <inherited>false</inherited>
> <executions>
> <execution>
> <id>integration-test-with-foo</id>
> <inherited>false</inherited>
> <goals>
> <goal>integration-test</goal>
> <goal>verify</goal>
> </goals>
> <configuration>
> <argLine>FOO</argLine>
> </configuration>
> </execution>
> </executions>
> </plugin>
> <plugins>
> </pluginManagement>
>
> Due to the use of <pluginManagement> instead of a plain <plugins> the 
> parent POM itself does not use this execution (as desired).
>
> Now, calling the "integration-test-with-foo" execution from a child 
> POM also works fine:
>
> <plugins>
> <plugin>
> <artifactId>maven-failsafe-plugin</artifactId>
> <executions>
> <execution>
> <id>integration-test-with-foo</id>
> </execution>
> </executions>
> </plugin>
> <plugins>
>
> But even if I don't call it at all from one of my child POMs, but 
> rather use a different plugin execution, "integration-test-with-foo" 
> still gets executed (along with "integration-test-with-bar"):
>
> <plugins>
> <plugin>
> <artifactId>maven-failsafe-plugin</artifactId>
> <executions>
> <execution>
> <id>integration-test-with-bar</id>
> <goals>
> <goal>integration-test</goal>
> <goal>verify</goal>
> </goals>
> <configuration>
> <argLine>BAR</argLine>
> </configuration>
> </execution>
> </executions>
> </plugin>
> <plugins>
>
> And that's something I don't understand. Isn't 
> <inherited>false</inherited> supposed to prevent this? (FWIW, this 
> happens using either Maven 2.2.0 or a recent 3.0-SNAPSHOT, so I 
> suppose its a bug in my understanding of <inherited> rather than in 
> Maven's.)
>
> Best wishes,
>
> Andreas Sewe
>
>
> ---------------------------------------------------------------------
> 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 executions vs. POM inheritance

Posted by Andreas Sewe <se...@st.informatik.tu-darmstadt.de>.
Hi Stephen,

I am in a situation similar to the OP's, so your reply made me refactor 
my POMs. (Its never to late to get rid of a little copy-n-paste :-)

But unfortunately I couldn't get your proposal to work. Here's the 
execution I configured in my parent POM, which I want to reuse in *some* 
of my child POMs:

<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.5</version>
<!-- Thrown in for good measure; I suspect I only need the 
execution-level inherited -->
<inherited>false</inherited>
<executions>
<execution>
<id>integration-test-with-foo</id>
<inherited>false</inherited>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<argLine>FOO</argLine>
</configuration>
</execution>
</executions>
</plugin>
<plugins>
</pluginManagement>

Due to the use of <pluginManagement> instead of a plain <plugins> the 
parent POM itself does not use this execution (as desired).

Now, calling the "integration-test-with-foo" execution from a child POM 
also works fine:

<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test-with-foo</id>
</execution>
</executions>
</plugin>
<plugins>

But even if I don't call it at all from one of my child POMs, but rather 
use a different plugin execution, "integration-test-with-foo" still gets 
executed (along with "integration-test-with-bar"):

<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test-with-bar</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<argLine>BAR</argLine>
</configuration>
</execution>
</executions>
</plugin>
<plugins>

And that's something I don't understand. Isn't 
<inherited>false</inherited> supposed to prevent this? (FWIW, this 
happens using either Maven 2.2.0 or a recent 3.0-SNAPSHOT, so I suppose 
its a bug in my understanding of <inherited> rather than in Maven's.)

Best wishes,

Andreas Sewe


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


Re: Plugin executions vs. POM inheritance

Posted by Stephen Connolly <st...@gmail.com>.
<inherited>false</inherited>

2010/1/28 Lóránt Pintér <lo...@gmail.com>

> Hi,
>
> I'm using the dependency plugin a lot to copy stuff around (mostly to
> get around the assembly plugin not allowing me to add arbitrary
> artifacts to assemblies). Some uses are general, and are needed in
> more than one module. AFAIK I should define these "general" executions
> in a parent POM, under the <pluginManagement> section, and "call" them
> from the actual modules by just specifying their execution ID, like:
>
> <plugin>
>        <artifactId>maven-dependency-plugin</artifactId>
>        <executions>
>                <execution>
>                        <id>unpack-all-swt</id>
>                </execution>
>                <execution>
>                        <id>unpack-all-native</id>
>                </execution>
>        </executions>
> </plugin>
>
> However, the thing above does not only execute the "unpack-all-swt"
> and "unpack-all-native" executions, but all other executions defined
> in the parent POM. This also applies if I don't refer to executions
> defined in parent at all, but define a new dependency plugin execution
> in the child module.
>
> It seems to me that if I "mention" a plugin in a child module, I get
> all its executions defined in <pluginManagement> in the parent as
> well. Is this as designed?
>
> If this is the way it should work, is there a way to achieve what I
> want? I.e. define some utility executions in parent that can be called
> in child modules, but independent of other executions.
>
> --
> Regards,
> Lóránt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>