跳过父项目中的 maven 插件
Skip maven plugin in parent project
我需要在父 pom 项目中跳过插件执行,但在子项目中执行它。这是怎么做到的?子项目在路径 ${basedir}/src/main/resources/${wsdl-name}.wsdl 中使用带有 wsdl 的 cxf-codegen-plugin,但父项目没有 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>
您将上述插件配置移动到<pluginManagement>
。然后添加到父 POM 的 <plugins>
部分:
<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>
我需要在父 pom 项目中跳过插件执行,但在子项目中执行它。这是怎么做到的?子项目在路径 ${basedir}/src/main/resources/${wsdl-name}.wsdl 中使用带有 wsdl 的 cxf-codegen-plugin,但父项目没有 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>
您将上述插件配置移动到<pluginManagement>
。然后添加到父 POM 的 <plugins>
部分:
<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>