Java file versioning

Hi All,
I have a javadoc tag @version in every class file.
When ever I change this file I need to increment the @version tag.
Is there any smart way of doing this in Intellij?

If not can somebody help me in achieveing this either within Intellij OR at the time of compilation!

Regards

5 comments

I would say that your best bet is to write a custom Ant
tag that would do this. It means you'd have to use Ant
rather than IDEA to do your compilation, but you're
probably already nearing the point where this is
necessary if your project requires that degree of change
control. The custom Ant tag you need is probably about a
hundred lines of Java, none of it difficult. The
O'Reilly Ant book is almost certainly your best how-to
resource for this task.

0


You don't need a custom ant task. The task (built into Ant 1.5+) does this already, and you can achieve this too with the property file. You'll need to look into using filter token and things like the task with filtering="true" (still referring to Ant here). Older versions of Ant can use the optional task for the same result. You might wish to increment the build number on each execution of the ant script that compiles the application, but only filter source files if you're invoking a target in your script that creates javadocs, as filtering files means that Ant will considered all source code as modified and try to compile it all (instead of just compiling changed files only, which is what it normally does and is much faster. I do this sort of versioning with Ant/IDEA all the time. - Chris "Dave Griffith" ]]> a ?crit dans le message de news:
9079559.1049852233780.JavaMail.jrun@is.intellij.net...

I would say that your best bet is to write a custom Ant
tag that would do this. It means you'd have to use Ant
rather than IDEA to do your compilation, but you're
probably already nearing the point where this is
necessary if your project requires that degree of change
control. The custom Ant tag you need is probably about a
hundred lines of Java, none of it difficult. The
O'Reilly Ant book is almost certainly your best how-to
resource for this task.



0

Most version control systems have a built-in mechanism for this. You simply
put some special token, which the VCS can recognise, into your source file
and it will get replaced automatically with whatever the current version
number is when you next check the file out. In CVS, for example, you would write

/**

  • @version $Revision:$

*/

and after check-out this will have been replaced by

/**

  • @version $Revision: 1.1$

*/

or something similar.

Hope that helps...

Vil.

Sanjeev wrote:

Hi All,
I have a javadoc tag @version in every class file.
When ever I change this file I need to increment the @version tag.
Is there any smart way of doing this in Intellij?

If not can somebody help me in achieveing this either within Intellij OR at the time of compilation!

Regards


--
Vilya Harvey, Consultant
vilya.harvey@digitalsteps.com / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457 http://www.digitalsteps.com/

Disclaimer

This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this email and you are not a named
addressee, please inform the sender at Digital Steps Ltd by phone on
+44 (0)1483 469 480 or by reply email and then delete the email from
your system. If you are not a named addressee you must not use,
disclose, distribute, copy, print or rely on this email. Although
Digital Steps Ltd routinely screens for viruses, addressees should
check this email and any attachments for viruses. Digital Steps Ltd
makes no representation or warranty as to the absence of viruses in this
email or any attachments.

0

Cool. I didn't know about ]]>, as I'm still on Ant 1.4.

0

Hi All,
Thank you all for your suggestions and tips.
I am taking Ant buildNumber approach.

Thanks and Regards
Sanjeev

0

Please sign in to leave a comment.