title: How to execute maven plugin before resources are filtered when using war packaging
body: <p><strong>Summary</strong></p>
  
  <p>The first phase for <code>&lt;packaging&gt;war&lt;/packaging&gt;</code> in the <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Built-in_Lifecycle_Bindings" rel="nofollow">Default Lifecycle</a> is for <code>process-resources</code> which immediately calls the <code>maven-resources-plugin</code>.  </p>
  
  <p>How can I execute a plugin before that runs? </p>
  
  <p>I was hoping there is an easy way to change the ordering when running <code>process-resources</code> to let the another plugin run first.</p>
  
  <p>Or perhaps force one of the earlier phases to be included in the lifecycle, 
   without going as far as <a href="https://community.jboss.org/wiki/CreatingACustomLifecycleInMaven?_sscc=t" rel="nofollow">Creating a custom lifecycle</a> </p>
  
  <p>(I'm actually surprised that <code>war</code> packaging doesn't use <code>validation</code> or <code>initialization</code> since they seem to make sense for any type of build)</p>
  
  <p><strong>Detail</strong></p>
  
  <p>I'm trying to use the <code>buildnumber-maven-plugin</code> to generate generate the <code>${buildNumber}</code> and use filtering to save it in the *.properties file which usually runs as part of the validate or initialize phase. So I tried to bind it to the <code>process-resources</code> phase for execution since it was the first.</p>
  
  <p>The problem is that <code>maven-resources-plugin</code> is the very first thing to execute before the <code>buildnumber-maven-plugin</code> has a chance to generate <code>${buildNumber}</code>.  All other properties are filtered fine.  (I'm aware I can probably do something in a later step with  <code>maven-war-plugin</code> using the <code>web.xml</code>, or in the manifest, but that's not what I'm asking)</p>
  
  <p>If they can't be reordered within process-resources, I was hoping I could force the <code>initialization</code> phase to be included in the lifecycle with some kind of easy configuration in the existing <code>pom.xml</code> </p>
  
  <p>Perhaps something that looks like the <code>components.xml</code> when defining the custom lifecycle.</p>
  
  <pre><code>&lt;configuration&gt;
              &lt;phases&gt;
                &lt;initialization&gt;org.codehaus.mojo:buildnumber-maven-plugin:create&lt;/initialization&gt;
              &lt;/phases&gt;
  &lt;/configuration&gt;
  </code></pre>