views:

334

answers:

3

Pardon me if this is a stupid question as I'm new to Java annotation. I'm looking into a solution that displays the subversion revision number and last modification date in my application (written in GWT, therefore reflection is not available). Encode the revision in subversion keyword doesn't work as it applies only to the current file. Is there a better solution using annotation? (e.g., a separate class that's executed during the compile time, grab the latest revision # on the whole project and inject the revision and last modification date to the source code)

Thanks,

+2  A: 
Jherico
SVN does not have this functionality. It was the cause of a lot of headaches in CVS, and was specifically dropped in SVN.
eqbridges
Indeed, personally I hate it in my source code, but removing the feature entirely seems like a pointless exercise.
Jherico
+2  A: 

Annotations are not really designed for this. It's easiest to do it as part of the build.

Using Ant you can generate a file that contains the version information, include it in your application's JAR, load it as a resource on the server, and serve it out to the browser-side code by RPC. Ant can also do string replacement in files as it copies them, which you can use to include the version number in your application's HTML files (no need for RPC then).

No idea about Maven, but I would be very surprised if it could not do the same kind of thing.

Nat
A: 

Subversion still has the $Id$ feature, but it needs to be enabled explicitly using the svn:keywords property on the files (set it to 'Id').

See also: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html

So the idea of Jherico above with @SvnRevision would work.

ankon