title: Maven advice relating to versioning of a large project and the avoidance of versions containing expressions
body: <p>I'm looking at restructuring a large Maven project...</p>
  
  <p><strong>A basic overview of our current structure:</strong></p>
  
  <pre><code>build [MVN plugins, third party dependency management]:5.1
     NRW Utils:6.0.0.0-beta12-SNAPSHOT
        server-utils:6.0.0.0-beta12-SNAPSHOT
        ... 
     CMW Root:6.0.0.0-beta12-SNAPSHOT
        cmw-webapp:6.0.0.0-beta12-SNAPSHOT
        cmw-core [dependencies on NRW Utils]:6.0.0.0-beta12-SNAPSHOT
        ...
     NRW Root :6.0.0.0-beta12-SNAPSHOT
        nrw-webapp [depends on NRW Utils &amp; CMW Root modules]:6.0.0.0-beta12-SNAPSHOT
        ...
  </code></pre>
  
  <p><strong>The reason for change:</strong></p>
  
  <p>The size of each collective module (i.e. NRW Utils, CMW Root and NRW Root) is getting larger and the build process is beginning to take an unbearable amount of time (~4hrs sometimes).</p>
  
  <p><strong>The new plan:</strong> </p>
  
  <pre><code>build [MVN plugins, third party dependency management]:5.1
     NRW Utils:6.0.0.0-NU-beta4-SNAPSHOT
        server-utils:6.0.0.0-NU-beta4-SNAPSHOT
        ... 
     CMW Root:6.0.0.0-CMW-beta12-SNAPSHOT
        cmw-webapp:6.0.0.0-CMW-beta12-SNAPSHOT
        cmw-core [dependencies on NRW Utils]:6.0.0.0-CMW-beta12-SNAPSHOT
        ...
     NRW Root :6.0.0.0-NRW-beta9-SNAPSHOT
        nrw-webapp [depends on NRW Utils &amp; CMW Root modules]:6.0.0.0-NRW-beta9-SNAPSHOT
        ...  
  </code></pre>
  
  <p>We have started introducing 'keys' in the version to distinguish between different 'collective modules' and hence can easily perform stepped releases. In addition, our utility modules are far more stable so we may not require nearly as many beta releases - there is now no restriction on keeping beta numbers in sync.</p>
  
  <p>It is also worth noting that there are in fact 5 different 'collective modules' (not just 3) all to be built with different versions (distinguished by unique keys) which is why I thought it'd be nice to have a centralised place for versions, as opposed to duplicate properties in 5 different POMs.</p>
  
  <p>The problem now lies in the contents of POM files when defining dependencies on modules in a different 'collective module' of a different version.</p>
  
  <p><strong>The proposed solution to dependency version management:</strong></p>
  
  <pre><code>build [MVN plugins, third party dependency management]:5.1
     nrw-version-management:6.0.0.0-beta-SNAPSHOT
        [contains properties defining latest versions of each collective module]   
        NRW Utils:6.0.0.0-NU-beta4-SNAPSHOT
           server-utils:6.0.0.0-NU-beta4-SNAPSHOT
           ... 
        CMW Root:6.0.0.0-CMW-beta12-SNAPSHOT
           cmw-webapp:6.0.0.0-CMW-beta12-SNAPSHOT
           cmw-core [dependencies on NRW Utils]:6.0.0.0-CMW-beta12-SNAPSHOT
           ...
        NRW Root :6.0.0.0-NRW-beta9-SNAPSHOT
           nrw-webapp [depends on NRW Utils &amp; CMW Root modules]:6.0.0.0-NRW-beta9-SNAPSHOT
           ... 
  </code></pre>
  
  <p><em>nrw-version-management (pom.xml):</em></p>
  
  <pre><code>...
  &lt;parent&gt;
      &lt;groupId&gt;com.project&lt;/groupId&gt;
      &lt;artifactId&gt;build&lt;/artifactId&gt;
      &lt;version&gt;5.1&lt;/version&gt;
  &lt;/parent&gt;
  &lt;groupId&gt;com.project&lt;/groupId&gt;
  &lt;artifactId&gt;nrw-versions-manager&lt;/artifactId&gt;
  &lt;version&gt;6.0.0.0-beta-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;Version Maven Properties&lt;/name&gt;
  &lt;description&gt;A centralised place for all module property versions&lt;/description&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;properties&gt;
      &lt;nrw.utilities.version&gt;6.0.0.0-NU-beta4-SNAPSHOT&lt;/nrw.utilities.version&gt;
      &lt;nrw.cmw.version&gt;6.0.0.0-CMW-beta12-SNAPSHOT&lt;/nrw.cmw.version&gt;
      &lt;nrw.version&gt;6.0.0.0-NRW-beta9-SNAPSHOT&lt;/nrw.version&gt;
  &lt;/properties&gt;
  ...
  </code></pre>
  
  <p><em>CMW Root (pom.xml):</em></p>
  
  <pre><code>...
  &lt;parent&gt;
      &lt;groupId&gt;com.project&lt;/groupId&gt;
      &lt;artifactId&gt;nrw-versions-manager&lt;/artifactId&gt;
      &lt;version&gt;${nrw.core.version}&lt;/version&gt;
      ...
  &lt;/parent&gt;
  &lt;groupId&gt;com.project&lt;/groupId&gt;
  &lt;artifactId&gt;CMW-root&lt;/artifactId&gt;
  &lt;version&gt;6.0.0.0-CMW-beta12-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          ...
          &lt;dependency&gt;
              &lt;groupId&gt;${project.groupId}&lt;/groupId&gt;
              &lt;artifactId&gt;server-utils&lt;/artifactId&gt;
              &lt;version&gt;${nrw.utilities.version}&lt;/version&gt;
          &lt;/dependency&gt;
          ...
  &lt;/dependencyManagement&gt;
  &lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;all&lt;/id&gt;
          &lt;modules&gt;
              &lt;module&gt;cmw-webapp&lt;/module&gt;
              &lt;module&gt;cmw-core&lt;/module&gt;
              ...
          &lt;/modules&gt;
      &lt;/profile&gt;
      ...
  &lt;/profiles&gt;
  ...
  </code></pre>
  
  <p>N.B. the property ${nrw.core.version} would then be set to 6.3.0.0-beta-SNAPSHOT for a snapshot build via command line arguments (or a default property value).</p>
  
  <p><strong>A possible release process (for 6.0.0.0):</strong></p>
  
  <ol>
  <li>Build the 5.1 build module if not already built</li>
  <li>Build nrw-version-management 6.0.0.0 (to avoid snapshot dependencies - however no properties are changed yet)</li>
  <li>Build NRW Utils 6.0.0.0-NU 
  cmd args: -Dnrw.core.version=6.0.0.0</li>
  <li>Build CMW Root 6.0.0.0-CMW
  cmd args: -Dnrw.core.version=6.0.0.0 -Dnrw.utilities.version=6.0.0.0-NU</li>
  <li>Build NRW Root 6.0.0.0-NRW
  cmd args: -Dnrw.core.version=6.0.0.0 -Dnrw.utilities.version=6.0.0.0-NU -Dnrw.cmw.version=6.0.0.0-CMW</li>
  <li>Re-build nrw-version-management 6.0.0.0 for repository
  cmd args: -Dnrw.core.version=6.0.0.0 -Dnrw.utilities.version=6.0.0.0-NU -Dnrw.cmw.version=6.0.0.0-CMW</li>
  <li>Build nrw-version-management 6.1.0.0-beta-SNAPSHOT with new dev versions and update POM file</li>
  </ol>
  
  <p><strong>The problem:</strong></p>
  
  <p>The build process seems long-winded, especially related to the nrw-version-management module.
  Also, I started seeing this warning:</p>
  
  <blockquote>
    <p>'version' contains an expression but should be a constant</p>
  </blockquote>
  
  <p>And having done some investigating I now understand expressions are not recommended when setting versions (when specifying a parent POM):</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1981151/warning-on-using-project-parent-version-as-the-version-of-a-module-in-maven-3">Warning on using project.parent.version as the version of a module in Maven 3</a></li>
  <li><a href="https://stackoverflow.com/questions/3684664/maven-property-substitution-not-done-for-project-version-tag-of-pom/">Maven: property substitution not done for /project/version tag of pom?</a></li>
  <li><a href="http://maven.40175.n5.nabble.com/Pom-Parent-Version-Properties-td124576.html" rel="nofollow noreferrer">http://maven.40175.n5.nabble.com/Pom-Parent-Version-Properties-td124576.html</a></li>
  </ul>
  
  <p><strong>The questions:</strong></p>
  
  <ul>
  <li>Can I just ignore this warning? Some posts are starting suggest that it might just be acceptable to specify parent POM versions using properties.</li>
  <li>Is this general approach conventional? Or flawed?</li>
  <li>Are there better solutions to address the re-structuring of this growing project?</li>
  </ul>
  
  <p>Thanks in advance.</p>