跳过父项目中的 Maven 插件

Aid*_*dyn 2 java maven-plugin pom.xml maven cxf-codegen-plugin

我需要在父 pom 项目中跳过插件执行,但在子项目中执行它。这是怎么做到的?子项目在路径${basedir}/src/main/resources/${wsdl-name}.wsdl中使用 cxf-codegen-plugin 和 wsdl ,但父项目没有 wsdl 。

在父 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>
Run Code Online (Sandbox Code Playgroud)

JF *_*ier 5

您将上述插件配置移至<pluginManagement>. 然后添加到<plugins>父 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>
Run Code Online (Sandbox Code Playgroud)