title: How to update the version of child modules in Maven?
body: <p>How to update the version of child modules?  There are a lot of Stackoverflow questions like this but I was not able to find one that fit this exact scenario... would love if this is a duplicate.</p>
  
  <p>Consider the following project.</p>
  
  <pre><code>parent
    --mod1
    --mod2
  </code></pre>
  
  <p>At the beginning of a dev release cycle I need to update the parent and modules to the same version.  If the version of the parent and modules stayed the same throughout the release then I would would just omit the <code>&lt;version&gt;</code> tag from the modules and execute <code>versions:set -DnewVersion=1.1.1</code> to kick off the dev cycle.  But as it turns out the modules do not all end the cycle with the same version.  As bugs and fixes materialize only those modules with the bugs and such get updated.  For example the parent and mod2 might be at version 1.1.1-RC1, but mod1 might be at 1.1.1-RC2.  </p>
  
  <p>As such I need to:<br>
  1) Include a <code>&lt;version&gt;</code> tag in the modules to track each modules version independently.</p>
  
  <p>2)  If mod2 requires mod1 as a dependency I need to make sure mod2 references the latest version of mod1.</p>
  
  <p>This leads to the following two questions.  </p>
  
  <p>1)  At the beginning of the cycle how can I set the parent and modules to the same version in one maven command?  I tried <code>version:set -DnewVersion=1.1.1</code>, but this only updates the parent's version across all the POM's but not the module's version.  I also tried <code>-N versions:update-child-modules</code>, but I think I am using it wrong because it does nothing, just shows skipped for all the modules.</p>
  
  <p>2)  This is a bit harder and matches to item 2 above.  How do I update both mod1's version and mod2's reference to mod1's version in one step?  I know how to do it in 2 steps:</p>
  
  <p>parent pom:</p>
  
  <pre><code>&lt;properties&gt;
      &lt;!-- update this manually if mod1's version no longer matches parent --&gt;
      &lt;mod1.version&gt;${project.version}&lt;/mod1.version&gt;
  &lt;/properties&gt;
  </code></pre>
  
  <p>mod2 pom:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;com.xxx&lt;/groupId&gt;
          &lt;artifactId&gt;mod1&lt;/artifactId&gt;
          &lt;version&gt;${mod1.version}&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>When mod1 bumps up to 1.1.1-RC2 I update the parent POM and mod1 POM to reflect this.  These are two steps.  Anyway to turn it into one step?</p>
  
  <p>My example was small but in real life there are many modules which makes this important time saver, plus I'm curious.</p>