Discussion:
Cannot specify which plugin <execution> to execute in child pom
djeddyg
2009-03-06 15:57:56 UTC
Permalink
Hi,

I have a project which consists of a parent POM and 2 child POMs, the parent
POM uses the exec-maven-plugin plugin and defines 2 <execute> elements, each
with a different <id> but bound to the same phase. I want to have one of my
child POMs inherit one <execution> and the other child POM inherit the other
<execution> hence I am referencing the appropriate <id> in each child POM.
No matter which <id> I reference in the child POM, both <execution> elements
are always executed in both child POMs.

Has anyone gotten this to work successfully? I have included snippits of my
3 POMs at the end of the mail so you can see exactly what I have done.

Many thanks,

Edd


Parent POM snippit:

<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>ExecDatabaseBuild</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-test-resources</phase>
<inherited>true</inherited>
<configuration>
<executable>sqlplus</executable>

<workingDirectory>${project.parent.basedir}/src/main/resources/db</workingDirectory>
<arguments>
<argument>${db.user}/${db.password}@${db.sid}</argument>
<argument>@1_create_db.sql</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>DoSomethingElse</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-test-resources</phase>
<inherited>true</inherited>
<configuration>
<executable>dir</executable>

<workingDirectory>${project.parent.basedir}/src/main/resources/db</workingDirectory>
<arguments>
<argument>/p</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>

And in one of my child POMs I have:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>DoSomethingElse</id>
</execution>
</executions>
</plugin>

And in the other child POM I have:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>ExecDatabaseBuild</id>
</execution>
</executions>
</plugin>
--
View this message in context: http://www.nabble.com/Cannot-specify-which-plugin-%3Cexecution%3E-to-execute-in-child-pom-tp22375228p22375228.html
Sent from the Maven - Users mailing list archive at Nabble.com.
Wayne Fay
2009-03-06 17:59:17 UTC
Permalink
I don't believe that what you are trying to do is possible in Maven.
Where did you get the idea that you could declare multiple executions
in a parent, and then specify the <id> in the child and only that
execution would be inherited?? Or was it just an idea/assumption that
you had which isn't working out for you?

Wayne
Post by djeddyg
Hi,
I have a project which consists of a parent POM and 2 child POMs, the parent
POM uses the exec-maven-plugin plugin and defines 2 <execute> elements, each
with a different <id> but bound to the same phase. I want to have one of my
child POMs inherit one <execution> and the other child POM inherit the other
<execution> hence I am referencing the appropriate <id> in each child POM.
No matter which <id> I reference in the child POM, both <execution> elements
are always executed in both child POMs.
Has anyone gotten this to work successfully? I have included snippits of my
3 POMs at the end of the mail so you can see exactly what I have done.
Many thanks,
Edd
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
 <execution>
   <id>ExecDatabaseBuild</id>
   <goals>
     <goal>exec</goal>
   </goals>
   <phase>process-test-resources</phase>
   <inherited>true</inherited>
   <configuration>
     <executable>sqlplus</executable>
<workingDirectory>${project.parent.basedir}/src/main/resources/db</workingDirectory>
     <arguments>
     </arguments>
   </configuration>
 </execution>
 <execution>
   <id>DoSomethingElse</id>
   <goals>
     <goal>exec</goal>
   </goals>
   <phase>process-test-resources</phase>
   <inherited>true</inherited>
   <configuration>
     <executable>dir</executable>
<workingDirectory>${project.parent.basedir}/src/main/resources/db</workingDirectory>
     <arguments>
       <argument>/p</argument>
     </arguments>
   </configuration>
 </execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
   <execution>
       <id>DoSomethingElse</id>
   </execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
   <execution>
       <id>ExecDatabaseBuild</id>
   </execution>
</executions>
</plugin>
--
View this message in context: http://www.nabble.com/Cannot-specify-which-plugin-%3Cexecution%3E-to-execute-in-child-pom-tp22375228p22375228.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
djeddyg
2009-03-06 19:44:33 UTC
Permalink
Hi Wayne,

I may have misunderstood the documentation but I got the idea from looking
at the following docs:

The http://maven.apache.org/guides/mini/guide-configuring-plugins.html
Maven guide to configuring plugins where they define 2 different
<execution> elements each with a different <id>.

Also the
http://maven.apache.org/ref/2.0.8/maven-model/maven.html#class_pluginManagement
Maven Model states that the <id> element is 'for matching exections to
merge during inheritance.'

The combination of the 2 documents made me think it should be possible to
use <id> to only inherit certain <execution> elements, is this not correct?

Many thanks,

Edd
Post by Wayne Fay
I don't believe that what you are trying to do is possible in Maven.
Where did you get the idea that you could declare multiple executions
in a parent, and then specify the <id> in the child and only that
execution would be inherited?? Or was it just an idea/assumption that
you had which isn't working out for you?
Wayne
Post by djeddyg
Hi,
I have a project which consists of a parent POM and 2 child POMs, the parent
POM uses the exec-maven-plugin plugin and defines 2 <execute> elements, each
with a different <id> but bound to the same phase. I want to have one of my
child POMs inherit one <execution> and the other child POM inherit the other
<execution> hence I am referencing the appropriate <id> in each child POM.
No matter which <id> I reference in the child POM, both <execution> elements
are always executed in both child POMs.
Has anyone gotten this to work successfully? I have included snippits of my
3 POMs at the end of the mail so you can see exactly what I have done.
Many thanks,
Edd
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
 <execution>
   <id>ExecDatabaseBuild</id>
   <goals>
     <goal>exec</goal>
   </goals>
   <phase>process-test-resources</phase>
   <inherited>true</inherited>
   <configuration>
     <executable>sqlplus</executable>
<workingDirectory>${project.parent.basedir}/src/main/resources/db</workingDirectory>
     <arguments>
     </arguments>
   </configuration>
 </execution>
 <execution>
   <id>DoSomethingElse</id>
   <goals>
     <goal>exec</goal>
   </goals>
   <phase>process-test-resources</phase>
   <inherited>true</inherited>
   <configuration>
     <executable>dir</executable>
<workingDirectory>${project.parent.basedir}/src/main/resources/db</workingDirectory>
     <arguments>
       <argument>/p</argument>
     </arguments>
   </configuration>
 </execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
   <execution>
       <id>DoSomethingElse</id>
   </execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
   <execution>
       <id>ExecDatabaseBuild</id>
   </execution>
</executions>
</plugin>
--
http://www.nabble.com/Cannot-specify-which-plugin-%3Cexecution%3E-to-execute-in-child-pom-tp22375228p22375228.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Cannot-specify-which-plugin-%3Cexecution%3E-to-execute-in-child-pom-tp22375228p22379253.html
Sent from the Maven - Users mailing list archive at Nabble.com.
Wayne Fay
2009-03-06 19:49:55 UTC
Permalink
Post by djeddyg
The combination of the 2 documents made me think it should be possible to
use <id> to only inherit certain <execution> elements, is this not correct?
I've never seen this done, never done it myself, and generally doubt
that it would work. Obviously your experiences would indicate it does
not.

I'd play with <inherited>true</> and your ids, check against "mvn
help:effective-pom" and see what you can get working. But I generally
do not expect this will work the way you want it too -- I'm happy to
be proven wrong, though.

Wayne

Loading...