0

We have a build properties file with the current global revision of the repository. This file was manually updated before someone tagged the project.

My idea is to write an ant task which updates the revision number in the properties file and set up a project builder in eclipse to execute the task. But the problem is, that you can only choose to run the task before or after a clean or on a manual or auto build.

Is there a way to execute the target before a commit, to ensure that the revision number is always updated?

Mario Pistrich
  • 488
  • 2
  • 5
  • 16

1 Answers1

1

Let your versioning tool do the work, it's his part.
Here's an example for a build file header that makes use of the cvs keywords when using cvs or cvsnt.
You might have seen this before in several sources, as it is good practice.
Other versioning tools like subversion .. etc. have similar features, just check their manuals,
f.e. see Subversion, keyword substitution

<?xml version="1.0" encoding="UTF-8"?>

 <!--+
     | $Author:$
     | $Date:$
     | $Revision:$
     |
     | Description :
     |  bla bla bla
     |  bla bla
     |  bla
     | 
     +-->



<project name="..." default="...">
  <description>
   description
  </description>
...

the cvs meta informations get updated automatically with every commit and you can't forget.
put those keywords in the file templates in your editor and you're done

But beware, your difftool will show differences for every file, even if only the revision number has changed because of branching. f.e. i use Eclipse and their difftool is not smart enough to ignore specific parts like those keywords
(still waiting for a plugin to fix that..). But after some time you will get used to ;-)
When working in a team, there has to be an agreement about using keywords or not before conflicts occur because of that diff problem.

Rebse
  • 10,307
  • 2
  • 38
  • 66
  • Thanks for the advice. I already considered this approach, but in SVN the keyword `$Revision$` represents the local revision of the file. I need the global revision in this file (It only consists of the revision number, which is used for several internal processes). – Mario Pistrich Aug 30 '11 at 18:53
  • oh, i thought svn is the wanna be successor to cvs ;-) ok, a bit of reasearch came up with http://stackoverflow.com/questions/438398/subversion-as-version-incrementor-at-each-commit/438429#438429 the post-commit combined with svnversion sounds good – Rebse Aug 30 '11 at 19:54