File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven or Ant: SVN revision Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven or Ant: SVN revision" Watch "Maven or Ant: SVN revision" New topic

Maven or Ant: SVN revision

Janko Mlakar

Joined: Mar 20, 2010
Posts: 7
Is it possible to gather SVN revision and add it to one java file (or automatically during build period using ant or maven?

I'm trying to get versioning based on SVN revision.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

For Ant, look at the svnant task, specifically the 'info' command:

That should get you the revision number into a property. Then use the copy task with an 'expandProperties' 'filterChain' to place the revision into the desired file.

JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

VCS version numbers make pretty lousy software release version numbers. I've been down that route, and they just don't track nicely. In CVS, it's compounded by the fact that each file has its own version number, based on the number of updates made to it.

I used have a "build version # bump" task in my Ant build files. Maven can do a complete release control action, including bumping the version number in the POM. It handles both snapshot (development release) versioning and production versioning.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Maven or Ant: SVN revision
It's not a secret anymore!