Easy way to access SVN revision in code?

Hello Chief-Delphi,

Our team uses a Subversion server to revise and store our code, and I was wondering if anyone knows a good, platform-independent way to access the SVN revision from within the code of the program.

I’ve seen a ANT build script that uses svnversion, but that would only work properly on Linux or OSX machines, and it doesn’t use the SVN client built-in to NetBeans on Windows.

If anyone has a good method of achieving this, I’d love to know :slight_smile: It’d be very helpful for the team I’m in, and likely many others that use Version Control.

-Sean “CyberKitsune”
Lead Programmer for the NeoBots

For the automated builds of the C++ WPILib libraries we use sliksvn (a command line svn tool) and a .vbs script that executes an svn command and gets the version number. It uses it to name the installer based on the svn version number.

Brad

Thank you for the quick reply, Brad!

Do you know if there is an easy way to do this with Java’s build system? (ANT)

This works for ant:

<condition property="isWindows">
    <os family="windows" />
</condition>

<target name="do.run.Windows" if="isWindows">
   <exec  executable="cmd" dir="${your-target-dir}" >
         <arg line="/C command-to-run arg1 arg2 arg3" />
   </exec>
</target>