title: How to run a plugin only for "war" package type in Maven?
body: <p>Provided two Maven projects: J (jar), W (war); both depend on one parent P (pom). The parent has a plugin, which must only run for the project "W". </p>
  
  <p>How does one go about doing this: </p>
  
  <ul>
  <li>without creating separate parent projects</li>
  <li>without using a profile (so build must still be executed with <code>mvn clean package</code>)</li>
  </ul>
  
  <p><strong><em>J (jar)</em></strong></p>
  
  <pre><code>&lt;project&gt;
    &lt;parent&gt;
      &lt;artifactId&gt;P&lt;/artifactId&gt;
    &lt;/parent&gt;
    &lt;artifactId&gt;J&lt;/artifactId&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong><em>W (war)</em></strong></p>
  
  <pre><code>&lt;project&gt;
    &lt;parent&gt;
      &lt;artifactId&gt;P&lt;/artifactId&gt;
    &lt;/parent&gt;
    &lt;artifactId&gt;W&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong><em>P (pom)</em></strong></p>
  
  <pre><code>&lt;project&gt;
    &lt;artifactId&gt;P&lt;/artifactId&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;
  
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;jar&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                &lt;classifier&gt;classes&lt;/classifier&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>