Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The easiest way of doing this is to change the problem. Instead of making the Any build do this for you, have whatever process that you're calling Ant calculate what the version number should be, and then pass that in as a property e.g.</p> <p>ant -Dbuild.version=1.2.3</p> <p>This has the flexibility of whatever build you're working with being able to take its cue from whatever, such as the SVN revision, the current date and time, or whatever.</p> <p>ant -Dbuild.version=<code>svnversion .</code></p> <p>ant -Dbuild.version=<code>date +"%Y%m%d%H%D"</code></p> <p>ant -Dbuild.version=${major}.<code>svnversion .</code>.<code>date +"%Y%m%d%H%D"</code></p> <p>etc. You can get pretty comprehensive if you want.</p> <p>If you want to have an ever incrementing number, then you can store it in a file and then pass that in at compile time. For example, you can do:</p> <p>VER=<code>cat build.version</code> VER=$((VER+1)) echo $VER > build.version</p> <p>Lastly, if you really want this to be in the build.xml file, the best thing to do is have a separate task to execute the increment-and-build option and fork off a nested ant build with your 'main' target. You'd thus end up with </p> <p>ant -> ant -Dbuild.version=1.2.3.4 -> ... </p> <p>In other words, given your build.xml with a (current) default of 'build', then change it to 'version' and have the ant 'version task do the calculation followed by a nested call to and build.</p> <p>Implementation is left as an exercise to the reader, as is translating the approach to a non-UNIX platform.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload