I recently I followed this great guide to integrate the subversion revision into exe/dll files generated from my c++/c# visual studio projects. Now I can easily right-click on an exe-file to find which revision was used to build the binary (see image below). I love this feature.
Is this possible to do the same in flash/flex when building air/stand-alone applications? I would like to tag both exe file and dlls.
(source: zachburlingame.com)
Update with solution:
Although the ANT-based solutions provided here aren't as smooth as the one where the svn info is burnt into .exe/.dll files (in my opinion), it has solved my problem and is now implemented in our productions. My setup is based both on Kevin's and frankhermes's answeres but uses SubMCRev.exe instead of svn.exe or jar files.
In our implementation we dump the svn revision to the logfile at startup. The output from the SVN target below looks like this:
Built with SVN Revision: 1.0.0.1181 (local modifications found)
SVN target:
<target name="SVN Revision">
<exec executable="subWCRev.exe" outputproperty="revision">
<arg value="${basedir}\\.." />
<redirector>
<outputfilterchain>
<linecontainsregexp>
<regexp pattern='^([Last]|[Local])' />
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern='[\D]+([\d]+)' replace="Built with SVN Revision: 1.0.0.\1" />
<replaceregex pattern='Local modifications found' replace=" (local modifications found)" />
</tokenfilter>
<striplinebreaks />
</outputfilterchain>
</redirector>
</exec>
</target>
Compile target:
<target name="compile" depends="init, SVN Revision">
<mxmlc file="..." output="...">
<define name="compile::REVISION" value="'${revision}'" />
....
</mxmlc>
</target>
We use the following method (and it's pretty similar to Kevin's answer but I can confirm that it works):
a snippet from my build.xml: this uses two jar files (svnkit and svntask) instead of svn.exe (so it runs cross-platform) - these jars are checked in via svn too so you can't lose them or misinstall.
<!-- SVN revision stuff -->
<typedef resource="com/googlecode/svntask/svntask.xml">
<classpath>
<fileset dir="${basedir}/util">
<include name="svnkit.jar"/>
<include name="svntask.jar"/>
</fileset>
</classpath>
</typedef>
<target name="revision">
<svn><info path="${basedir}" revisionProperty="revision" /></svn>
<echo>${revision}</echo>
</target>
<!-- /SVN revision stuff -->
Now we have the revision in a property that we include in the mxmlc task as a conditional compiler variable:
<mxmlc file="${src.dir}/@{appfile}.@{ext}"
output="@{output}/@{appfile}.swf"
debug="@{debug}"
target-player="${version_major}"
optimize="true"
locale=""
use-network="true"
>
<define name="compile::REVISION" value="'${revision}'"/>
[... rest snipped]
</mxmlc>
Then you can use that variable in AS:
var version:String = "1.0."+compile::REVISION;
For the code to work in Flash Builder too, you'd have to add the following line to your additional compiler arguments:
-define+=compile::REVISION,'dev'
That way your development code will have the revision 'dev', indicating that it was not necessarily built from a committed version of the code.