title: Using Maven and Apache CXF code-gen with different endpoints in testing and production
body: <p>I have a Java web project that consumes a web service, using Apache CXF to generate the underlying code, based on the WSDL published by the service.</p>
  
  <p>I have a test version of the service for development and a production version.
  The endpoints of the 2 services are at different URLs and whilst their public interfaces are pretty much identical I regenerate the CXF code (using the cxf-codegen-plugin) as I promote my project to the production environment.</p>
  
  <p>What is the best way to configure Maven to do this?</p>
  
  <p>At the moment I set a property in the <code>pom.xml</code> called <code>ws_status</code></p>
  
  <pre><code>&lt;properties&gt;
      &lt;ws_status&gt;test&lt;/ws_status&gt;
  &lt;/properties&gt;
  </code></pre>
  
  <p>which I subsequently use to tweak the path to the WSDL file used by the codegen plugin:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
      &lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt;
      &lt;version&gt;${cxf.version}&lt;/version&gt;
      &lt;configuration&gt;
      &lt;fork&gt;once&lt;/fork&gt;
      &lt;encoding&gt;UTF-8&lt;/encoding&gt;
      &lt;additionalJvmArgs&gt;-Djava.endorsed.dirs=${project.build.directory}/endorsed&lt;/additionalJvmArgs&gt;
      &lt;!-- rest of the normal codegen configuration options --&gt;
      &lt;/configuration&gt;
      &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
          &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
          &lt;artifactId&gt;jaxb-xjc&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;executions&gt;
      &lt;execution&gt;
          &lt;id&gt;generate-sources&lt;/id&gt;
          &lt;phase&gt;generate-sources&lt;/phase&gt;
          &lt;goals&gt;
          &lt;goal&gt;wsdl2java&lt;/goal&gt;
          &lt;/goals&gt;
          &lt;configuration&gt;
          &lt;wsdlOptions&gt;
              &lt;wsdlOption&gt;
              &lt;wsdl&gt;${basedir}/src/main/resources/wsdl/${ws_status}/Cmis.wsdl&lt;/wsdl&gt;
              &lt;wsdlLocation&gt;classpath:wsdl/${ws_status}/Cmis.wsdl&lt;/wsdlLocation&gt;
              &lt;extraargs&gt;
                  &lt;extraarg&gt;-client&lt;/extraarg&gt;
                  &lt;extraarg&gt;-verbose&lt;/extraarg&gt;
                  &lt;extraarg&gt;-compile&lt;/extraarg&gt;
              &lt;/extraargs&gt;
              &lt;/wsdlOption&gt;
          &lt;/wsdlOptions&gt;
          &lt;/configuration&gt;
      &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>This works OK, but it annoys me that I need to change the <code>ws_status</code> inside the <code>pom.xml</code> every time I release a production version, as the pom file is tracked by git.</p>
  
  <p>What I want is a maven command-line switch to tell it to refer to one WSDL file or the other , so I can generate the sources for the test or production environment without having to change the code inside the project. Is this the "build profile" in Maven speak?</p>
  
  <p>Any ideas? Thanks.</p>