6

我正在寻找一种在安装时不执行插件的方法。更具体地说,我的情况如下:

  1. 我正在使用 org.apache.cxf:cxf-codegen-plugin 生成源代码。
  2. 每次我清理+安装源都会生成
  3. 我只希望在我明确请求时生成源代码。

任何和所有的帮助将不胜感激!

4

2 回答 2

12

I only want generation of source code to happen when I explicitly request it.

The best option would be to add the plugin declaration in a profile and to explicitly activate this profile:

<project>
  ...
  <profiles>
    <profile>
      <id>codegen</id>
      ...
      <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/cxf</sourceRoot>
                  <wsdlOptions>
                    <wsdlOption>
                      <wsdl>${basedir}/src/main/wsdl/myService.wsdl</wsdl>
                    </wsdlOption>
                  </wsdlOptions>
                </configuration>
                <goals>
                  <goal>wsdl2java</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

And run the following when you want the code generation to happen:

mvn clean install -Pcodegen
于 2010-04-08T00:12:01.383 回答
0

我相信您想在您的 POM 中向 cxf 的插件元素添加一个执行元素。您应该能够将生成目标绑定到您喜欢的阶段。见:http ://maven.apache.org/pom.html#Plugins

于 2010-04-07T23:05:13.890 回答