You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Markus Jostock <ma...@softwareag.com> on 2008/10/31 09:35:45 UTC

Blocking an inherited plugin

Dear all

I have a little application with three sub-modules. There is a parent 
child relation between the parent app and the sub-modules.
The parent application generates code for the three sub-modules via an 
antrun plugin in the "generate-sources" phase. This works fine. Then 
each of the sub modules should compile and package the generated code 
into a jar.

Unfortunately, when the sub-modules reach the "generate-sources" phase, 
they also try to run the inherited code generation plugin. But this 
obviously fails, since code generation is only valid for the parent POM 
and not for the sub-module POMs.

Is there a way I can block my plugin (defined in the parent POM) from 
being executed in the sub-modules ???

Many many thanks for your advice

  Markus


Here the parent POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.my.app</groupId>
  <artifactId>MyParentApp</artifactId>
  <name>MyParentApp</name>
  <version>1.0</version>
  <packaging>pom</packaging>
 
  <modules>
    <module>module-1</module>
    <module>module-2</module>
    <module>module-3</module>
  </modules>
 
  <dependencies>
  </dependencies>
 
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.1</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <tasks>
                <!-- generate code for module1...3 via an ant build 
script -->
                <property name="some.property" value="some.value"/>
              
                <ant antfile="build.xml" 
target="generate-code-for-module-1"/>
                <ant antfile="build.xml" 
target="generate-code-for-module-2"/>
                <ant antfile="build.xml" 
target="generate-code-for-module-3"/>

              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
 
</project>


Here one child POM:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
 
    <parent>
      <artifactId>MyParentApp</artifactId>
      <groupId>com.my.app</groupId>
      <version>1.0</version>
    </parent>
 
  <groupId>com.my.app</groupId>
  <artifactId>module-1</artifactId>
  <name>module-1</name>
  <version>1.0</version>
 
  <dependencies>
    ...
  </dependencies>
 
</project>






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


Re: Blocking an inherited plugin

Posted by Piotr Oktaba <pi...@coconet.pl>.
Hi,

you can add 'inherited' element into your plugin configuration:

      </plugin>
        ....
        <inherited>false</inherited>
        ....
      </plugin>

>>From maven site:

inherited: true or false, whether or not this plugin configuration
should apply to POMs which inherit from this one.

For more details please follow link:
http://maven.apache.org/pom.html#Plugins

Cheers,
Piotrek


On Fri, 2008-10-31 at 09:35 +0100, Markus Jostock wrote:

> Dear all
> 
> I have a little application with three sub-modules. There is a parent 
> child relation between the parent app and the sub-modules.
> The parent application generates code for the three sub-modules via an 
> antrun plugin in the "generate-sources" phase. This works fine. Then 
> each of the sub modules should compile and package the generated code 
> into a jar.
> 
> Unfortunately, when the sub-modules reach the "generate-sources" phase, 
> they also try to run the inherited code generation plugin. But this 
> obviously fails, since code generation is only valid for the parent POM 
> and not for the sub-module POMs.
> 
> Is there a way I can block my plugin (defined in the parent POM) from 
> being executed in the sub-modules ???
> 
> Many many thanks for your advice
> 
>   Markus
> 
> 
> Here the parent POM:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
> http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
> 
>   <groupId>com.my.app</groupId>
>   <artifactId>MyParentApp</artifactId>
>   <name>MyParentApp</name>
>   <version>1.0</version>
>   <packaging>pom</packaging>
>  
>   <modules>
>     <module>module-1</module>
>     <module>module-2</module>
>     <module>module-3</module>
>   </modules>
>  
>   <dependencies>
>   </dependencies>
>  
>   <build>
>     <plugins>
>       <plugin>
>         <artifactId>maven-antrun-plugin</artifactId>
>         <version>1.1</version>
>         <executions>
>           <execution>
>             <phase>generate-sources</phase>
>             <configuration>
>               <tasks>
>                 <!-- generate code for module1...3 via an ant build 
> script -->
>                 <property name="some.property" value="some.value"/>
>               
>                 <ant antfile="build.xml" 
> target="generate-code-for-module-1"/>
>                 <ant antfile="build.xml" 
> target="generate-code-for-module-2"/>
>                 <ant antfile="build.xml" 
> target="generate-code-for-module-3"/>
> 
>               </tasks>
>             </configuration>
>             <goals>
>               <goal>run</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
>  
> </project>
> 
> 
> Here one child POM:
> 
> <project xmlns="http://maven.apache.org/POM/4.0.0"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
> http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>  
>     <parent>
>       <artifactId>MyParentApp</artifactId>
>       <groupId>com.my.app</groupId>
>       <version>1.0</version>
>     </parent>
>  
>   <groupId>com.my.app</groupId>
>   <artifactId>module-1</artifactId>
>   <name>module-1</name>
>   <version>1.0</version>
>  
>   <dependencies>
>     ...
>   </dependencies>
>  
> </project>
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>