title: Maven with Jenkins - Update parent pom version of dependency
body: <p>I have a pom file that looks similar to this</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/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;myApp&lt;/groupId&gt;
    &lt;artifactId&gt;myAppId&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;1.2-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;Maven Test Webapp&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;dependency&gt;
        &lt;groupId&gt;com.manydesigns&lt;/groupId&gt;
        &lt;artifactId&gt;portofino-war&lt;/artifactId&gt;
        &lt;version&gt;3.1.10&lt;/version&gt;
        &lt;type&gt;war&lt;/type&gt;
        &lt;scope&gt;compile&lt;/scope&gt;
    &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
    &lt;build&gt;
      &lt;finalName&gt;TestName&lt;/finalName&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>If i run 'mvn release:prepare' on the above pom file, the version of the artifact changes. i.e. it becomes</p>
  
  <pre><code>&lt;version&gt;1.2&lt;/version&gt;
  </code></pre>
  
  <p>Now lets say i have gone and updated the portofino-war application which is a dependency of this pom file. portofino-war is now at version 3.1.11 but the parent pom file points to version 3.1.10 as shown above. </p>
  
  <p>Is there any way i can update the parent pom (either via Maven or Jenkins) file if a new version of portofino-war is built?</p>
  
  <p>Thanks</p>
  
  <h2>Edit</h2>
  
  <p>The application uses Maven overlays - <a href="http://maven.apache.org/plugins/maven-war-plugin/overlays.html" rel="nofollow">http://maven.apache.org/plugins/maven-war-plugin/overlays.html</a> to build a war file from other war files. This means that if any of the dependent modules are built, the parent module has to be built to produce the final war file.</p>
  
  <p>The problem is that at the moment if i build any of the modules, i have to manually update the version in the parent pom file to build using the correct module version. </p>
  
  <h2>Edit 2</h2>
  
  <p>Thanks for your help Ralph. Basically this is what i would like to achieve:</p>
  
  <p>What i am trying to do is create a maven project that will build a war file based on several modules. Assume the modules have the following structure:</p>
  
  <p>Module 1</p>
  
  <pre><code>customerModule
      |-webapp
          |-jsp
              |-customer
                  |-findCustomer.jsp
                  |-addNewCustomer.jsp
                  |-deleteCustomer.jsp
      |-src
          |-com
              |-mycompany
                  |-customer
                      |-FindCustomerAction.java
                      |-AddCustomerAction.java
                      |-DeleteCustomer.java
  </code></pre>
  
  <p>Module2</p>
  
  <pre><code>productModule
      |-webapp
          |-jsp
              |-product
                  |-productCustomer.jsp
                  |-addNewProduct.jsp
                  |-deleteProduct.jsp
      |-src
          |-com
              |-mycompany
                  |-product               
                      |-FindProductAction.java
                      |-AddProductAction.java
                      |-DeleteProduct.java 
  </code></pre>
  
  <p>Module3</p>
  
  <pre><code>commonModule
      |-webapp
          |-css
              |-style.css
          |-jsp
              |-templates
                  |-coreTemplate.jsp
      |-src
          com
              |-mycomany
                  |-common
                      |-Logger.java
                      |-Access.java
      |-META-INF
          |-MANIFEST.MF
          |-context.xml
      |-WEB-INF
          |-lib
              |-oraclejdbc.lib
              |-log4j.lib
              |-common.lib
          |-struts-config.xml
          |-tiles-def.xml
          |-web.xml
  </code></pre>
  
  <p>Each of the modules shown will be developed by a different team. Each team produces a war file and installs it in the local maven repository. As an example the repository could look like this</p>
  
  <pre><code>com
   |-customerModule
      |-customerModule.v2.1.war
      |-customerModule.v3.0.war
   |-productModule
      |-productModule.v3.0.war
      |-productModule.v3.1.war    
   |-commonModule
      |-commonModule.v0.5.war 
      |-commonModule.v3.0.war 
  </code></pre>
  
  <p>Now the build manager uses the above war files to build the final deployable war file. I was originally planning to use maven overlays to merge the three war files. I did test the merging of war files with overlays and found that the following configuration worked. i.e. using dependencies:</p>
  
  <p>Note: These dependencies are in the commonModule pom file</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;com&lt;/groupId&gt;
    &lt;artifactId&gt;customerModule&lt;/artifactId&gt;
    &lt;version&gt;3.0&lt;/version&gt;
    &lt;type&gt;war&lt;/type&gt;
    &lt;scope&gt;compile&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;com&lt;/groupId&gt;
    &lt;artifactId&gt;productModule&lt;/artifactId&gt;
    &lt;version&gt;3.1&lt;/version&gt;
    &lt;type&gt;war&lt;/type&gt;
    &lt;scope&gt;compile&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>If i then build the commonModule module, i end up with one war file that contains all the contents of Module1, Module2 and Module3. Which ends up with something like this:</p>
  
  <pre><code>MyApp.war
      |-webapp
          |-css
              |-style.css
          |-jsp
              |-customer
                  |-findCustomer.jsp
                  |-addNewCustomer.jsp
                  |-deleteCustomer.jsp
              |-product
                  |-productCustomer.jsp
                  |-addNewProduct.jsp
                  |-deleteProduct.jsp     
              |-templates
                  |-coreTemplate.jsp
      |-META-INF
          |-MANIFEST.MF
          |-context.xml
      |-WEB-INF
          |-lib
              |-oraclejdbc.lib
              |-log4j.lib
              |-common.lib
              |-customerModule.jar
              |-productModule.jar
          |-classes
              |-com
                  |-mycomany
                      |-common
                          |-Logger.class
                          |-Access.class
          |-struts-config.xml
          |-tiles-def.xml
          |-web.xml   
  </code></pre>
  
  <p>The above works but requires a bit of manual intervention for a full release. Here is an example of what would happen if a module is modified</p>
  
  <p>Team 1 updating module 1</p>
  
  <pre><code>- Team 1 makes changes to module 1 and check in changes into CVS    
  - Team 1 installs module 1 onto the maven repository by issuing mvn:prepare and mvn:perform on module 1. This adds a new version of customerModule.war on to the local repository
  - Team 1 updates the dependency version for module 1 in the pom file used to merge the war files (i.e. commonModule)
  - Team 1 builds the deployable war file by building the commonModule. 
  </code></pre>
  
  <p>The above does not use a multi module project as you suggested so i am trying to understand how the versioning would work with multi module projects. For example, lets say the multi module project will look like this</p>
  
  <pre><code>MyApp
   |- productModule
      |-pom.xml
   |- customerModule
      |-pom.xml
   |- commonModule
      |-pom.xml
   |-pom.xml
  </code></pre>
  
  <ul>
  <li>What is the difference in adding the version number in each child module compared to just havin the version number on the parent?</li>
  <li>You say that the child modules will use the parent version. Lets say the parent version is currently version 3.4, how will it know that it is supposed to use version 3.1 of the productModule.war?</li>
  <li>And finally, if team 1 has made a change to one of the child modules, would they still need to build it and deploy it on to the maven repository as an individual product first before building the multi-module project or can this be done as one step?</li>
  <li>How would this work if i want to make a patch release that does not necessarily mean using the latest version of a specific module?</li>
  </ul>
  
  <p>Thanks</p>