title: Maven build war modules into an ear
body: <p>I have a maven project with ear packaging, including two webModule and dependencies to maven WAR package. Whenever I build changes, I need first to manually build the two war via "maven clean install" and in the end I build the ear always via "maven clean install".</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;it.test.esempio.fe&lt;/groupId&gt;
          &lt;artifactId&gt;ESEMPIO_FE_PTL_PARENT&lt;/artifactId&gt;
          &lt;version&gt;1.32.0-SNAPSHOT&lt;/version&gt;
          &lt;relativePath&gt;../pom.xml&lt;/relativePath&gt;
      &lt;/parent&gt;
      &lt;artifactId&gt;ESEMPIO_FE_TEMA_COMPLETO&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;ear&lt;/packaging&gt;
      &lt;dependencies&gt;
          &lt;!-- START: PROJECT DEPENDENCIES --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;it.test.esempio.fe&lt;/groupId&gt;
              &lt;artifactId&gt;ESEMPIO_FE_TEMA_COMPLETO_STATICO&lt;/artifactId&gt;
              &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
              &lt;type&gt;war&lt;/type&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;it.test.esempio.fe&lt;/groupId&gt;
              &lt;artifactId&gt;ESEMPIO_FE_TEMA_COMPLETO_DINAMICO&lt;/artifactId&gt;
              &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
              &lt;type&gt;war&lt;/type&gt;
          &lt;/dependency&gt;
          &lt;!-- END: PROJECT DEPENDENCIES --&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-ear-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.10.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;version&gt;6&lt;/version&gt;
                      &lt;modules&gt;
                          &lt;webModule&gt;
                              &lt;groupId&gt;it.test.esempio.fe&lt;/groupId&gt;
                              &lt;artifactId&gt;ESEMPIO_FE_TEMA_COMPLETO_DINAMICO&lt;/artifactId&gt;
                              &lt;bundleFileName&gt;ESEMPIO_FE_TEMA_COMPLETO_DINAMICO.war&lt;/bundleFileName&gt;
                              &lt;contextRoot&gt;wps/ESEMPIO_FE_TEMA_COMPLETO_DINAMICO&lt;/contextRoot&gt;
                          &lt;/webModule&gt;
                          &lt;webModule&gt;
                              &lt;groupId&gt;it.test.esempio.fe&lt;/groupId&gt;
                              &lt;artifactId&gt;ESEMPIO_FE_TEMA_COMPLETO_STATICO&lt;/artifactId&gt;
                              &lt;bundleFileName&gt;ESEMPIO_FE_TEMA_COMPLETO_STATICO.war&lt;/bundleFileName&gt;
                              &lt;contextRoot&gt;wps/ESEMPIO_FE_TEMA_COMPLETO_STATICO&lt;/contextRoot&gt;
                          &lt;/webModule&gt;
                      &lt;/modules&gt;
                      &lt;defaultLibBundleDir&gt;lib&lt;/defaultLibBundleDir&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Is it possible to make in way to automatically build the 2 war and the ear with only one build command?</p>
  
  <p>Thanks a lot</p>