title: Build numbers: major.minor.revision
body: <p>How would you write a <code>build.xml</code> file, using neither custom code nor external dependencies (such as a shell script), that:</p>
  
  <ul>
  <li>Generates a build number of the form major.minor.revision (e.g., <strong>01.02.34</strong>).</li>
  <li>Auto-increments the revision on each compile of the source code.</li>
  <li>Auto-increments the minor version on each execution of a dist(ribution) task.</li>
  </ul>
  
  <p>Additionally:</p>
  
  <ul>
  <li>Provides an option to increment the major number.</li>
  <li>Provides an option to increment the minor number.</li>
  <li>Whenever the major number is incremented, the minor and revision numbers are set to 0.</li>
  <li>Whenever the minor number is incremented, the revision number is set to 0.</li>
  </ul>
  
  <p>Bonus:</p>
  
  <ul>
  <li>Creates a variable based on the <code>git</code> revision number (like a subversion revision number).</li>
  </ul>
  
  <p>Clarification:</p>
  
  <ul>
  <li>Automatic checkout (or commit) is not required.</li>
  <li>Integration with Subversion is not desired.</li>
  </ul>
  
  <p>Thank you for any examples. Here are some related sites that describe how to perform similar tasks:</p>
  
  <ul>
  <li>Create a <a href="http://www.innovationontherun.com/creating-a-build-number-with-ant-and-subversion/" rel="nofollow noreferrer">Build Number</a> with Ant.</li>
  <li>Using the <a href="http://ant.apache.org/manual/Tasks/buildnumber.html" rel="nofollow noreferrer">BuildNumber</a> Ant task.</li>
  <li>Ant and <a href="http://www.bright-green.com/blog/2005_09_26/ant_and_build_version_numbers.html" rel="nofollow noreferrer">Build Version</a> Numbers.</li>
  </ul>