javamavenpom.xmlmaven-plugincxf-codegen-plugin

Skip maven plugin in parent project


I need skip plugin execution in parent pom project, but execute it in child projects. How do it this? Child projects use cxf-codegen-plugin with wsdl in path ${basedir}/src/main/resources/${wsdl-name}.wsdl, but parent project dont'n have wsdl.

Build => plugins in parent pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/${wsdl-name}.wsdl</wsdl>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
                ...
        </plugins>
    </build>

Solution

  • You move the above plugin configuration to <pluginManagement>. Then you add to the <plugins> section of your parent POM:

    <plugin>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-codegen-plugin</artifactId>
      <executions>
         <execution>
           <id>generate-sources</id>
           <inherited>false</inherited>
           <phase>none</phase>
         </execution>
      </executions>
    </plugin>