6

I am looking for a way to not have a plugin execute on install. More specifically, my scenario is as follows:

  1. I am using org.apache.cxf:cxf-codegen-plugin to generate source code.
  2. Every time I clean+install the source is generated
  3. I only want generation of source code to happen when I explicitly request it.

Any and all help would be greatly appreciated!

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
Octoberdan
  • 460
  • 5
  • 10

2 Answers2

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
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • OP should want to code generation to be enabled by default and disabled on request! This is kinder to other developers (who won't have an error because they forgot the code generation) and somehow simplifies the CI setup. – marcv81 Nov 04 '15 at 02:24
0

I believe you want to add an executions element to cxf's plugin element in your POM. You should be able to bind the generation goal to the phase you'd prefer. See: http://maven.apache.org/pom.html#Plugins

JavadocMD
  • 4,397
  • 2
  • 25
  • 23