title: Packaging WSDL clients in JARs with Maven and cxf-codegen-plugin
body: <p>I've got a maven project that will consume a number of webservices. The application will be packaged as a WAR. So far the clients' code has been generated with <code>cxf-codegen-plugin</code>, in the <code>generate-sources</code> phase. By default, generated sources are placed into <code>target/generated-sources/cxf</code>, and after <code>compile</code>, they are compiled and mixed up with the application classes in <code>target/classes</code>. Both the generated and application classes can share the first level packages.</p>
  
  <p>I'd like each of the clients to be packaged in its own JAR inside <code>WEB-INF/lib</code> in the WAR file. I found out about <code>-clientjar</code>, but it only generates the <code>.jar</code> files and places them into <code>target/generated-sources/cxf</code>, and the JARs also end up in <code>target/classes</code> along with the compiled classes, which is pointless.</p>
  
  <p>I suppose the <code>compile</code> plugin at some point is compiling the generated sources into <code>target/classes</code>, and possibly another phase is also moving the JARs there. Would it be possible to have Maven avoid compiling those generated sources (or even have <code>cxf-codegen-plugin</code> generate no sources at all, only the JARs), and compile the application classes against the JARs generated by CXF?</p>
  
  <p>I know it would be possible to achieve this by defining a multimodule project with a jar packaging module for each webservice, but I'd like to avoid this option. There can be a large number of webservices and it would not be suitable to maintain an independent module for each one. With <code>-clientjar</code> I'm already forced to define a <code>&lt;wsdlOption&gt;</code> for each WSDL in order to provide the JAR name for each WSDL (it's not possible to let <code>cxf-codegen-plugin</code> just scan <code>src/main/resources/wsdl</code> or <code>&lt;wsdlRoot&gt;</code>). </p>
  
  <p>Of course the client JARs could be generated outside Maven and installed to a local repository, and be defined as dependencies in the project, but I'd like to know if it's possible to do this in a single Maven build.</p>
  
  <p>With assemblies I'd probably sort out how to place the JAR files generated by <code>-clientjar</code> into <code>WEB-INF/lib</code> but there would still be an issue with the generated classes inside the WAR.</p>
  
  <p>I don't have a deep knowledge of the Maven build lifecycle and its possibilities, any suggestions or pointers are very much welcome.</p>