You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by rtroeg <ri...@coremedia.com> on 2009/12/15 10:13:46 UTC

plugin is executed twice when using custom lifecycle

Hello,

i have a project with a parent pom and a child pom.
My objective is to achieve a child pom that is as small/simple as possible.
The child pom is supposed to use a custom lifecycle that is added to the pom
as an extension (lifecycle is defined in components.xml). 
In the parent pom the configurations of multiple plugins are included in
pluginManagement like this:

       <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.4.1</version>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>.</outputDirectory>
                <resources>
                  <resource>
                    <directory>resources/plain</directory>
                  </resource>
                  <resource>
                    <directory>resources/filtered</directory>
                    <filtering>true</filtering>
                  </resource>
                </resources>
              </configuration>
        </plugin> 

( The important part here is that i do not need to use the
<execution>-element ) 
The executions of these plugins are triggered by the lifecycle so there is
no need to add the plugins 
to the inheriting pom. 
The result is: The inheriting is nearly empty.

There is just one plugin where this approach does not work:

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
          <executions>
            <execution>
              <id>unpack-template</id>
              <phase>generate-resources</phase>
              <goals>
                <goal>unpack-dependencies</goal>
              </goals>
              <configuration>
               
<includeGroupIds>com.coremedia.cms,${project.groupId}</includeGroupIds>
                <includeTypes>zip</includeTypes>
               
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
              </configuration>
            </execution>

            <execution>
              <id>copy-jars</id>
              <phase>generate-resources</phase>
              <goals>
                <goal>copy-dependencies</goal>
              </goals>
              <configuration>
               
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
                <includeScope>runtime</includeScope>
                <includeTypes>jar</includeTypes>
              </configuration>
            </execution>
          </executions>
        </plugin>

Since there are two goals configured that belong to one plugin i need to use
the <execution>-element so that maven can distuinguish between the
configurations of the goals. Havin the execution tags( even in
pluginManagement) triggers the execution of the goals . But since they are
also added to the custom lifecycle their execution is triggered from there
as well. 
When i build the roject the result is:
The goals are first executed without configuration by means of the custom
lifecycle defined in my components.xml. After that the goals in the parent
pom are executed again with the configuration.

So my question is: 
Is there a way to specify a plugin with two goals without using the
execution-element? or
Is there a way to tell the execution to only execute when triggered by the
custom lifecycle?

Hope the lengthy description is understandable. Thansk in advance for taking
the time to read.
Would be fantastic to hear from someone who knows a bit about this
problem...

Rick 
-- 
View this message in context: http://old.nabble.com/plugin-is-executed-twice-when-using-custom-lifecycle-tp26791784p26791784.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