| |||||||||
Automated copy/paste using ANT
Automated copy/paste using ANTIn our time, we have found that certain parts of a release spans not only the application, but also the documentation (whether it be text files, or home pages). In order to maintain a certain level of professionalism, Such information needs be updated upon each release. If this is not automated, you will be reluctant to do frequent releases, or any kind of release at all. At other times, you have information you have static information you would like to supply in many files such as copyright notices and other lincense information. Such information is very important to have explicit in your code. While this information may change infrequently, it often seems to be "in the way" of what you as a developer really want to do (i.e. read the non-static text ;-). The problem is two-fold. How do we automate the updation of information that cross-cuts code and documentation, and how do we hide "static information" which ultimately, is only there for the users and to you just seems to obstruct your reading.Solution Ant Build ScriptThe solution to both problems is to insert "magic markers" in your files and have these be expanded to text upon compilation before a release. The markers can denote version numbers, copyright notices etc. which then automatically are repleced during the release-build. If your product is open-source and you supply both source code and binary files, it is important to replace the magic markers before compiling the binary files otherwise line numbers reported by the code will not match the released source code. The "magic markers" can be placed in xml files, html files, source code etc. which ensures that the information is always the same. This is an alternative to using astatic final String VERSION = "3.14"; since this information is only available to the source code.
Ant supports a very easy way to search/replace values in files. Magic markers and their corresponding values are defined in a properties file. Here is how you do it
CommentsIf you have any comments to this article, please drop me a mail at firstclassthoughts at gmail dot com please indicate if I can't publish whole or parts of your comment on the site.If you like this site consider Help spread the wordShare this post on your favorite social bookmarking sites:
The most recent contributions 28/07/09 Magic in mathematics II Fun with the number cyclic numbers, and specifically with 142857 as it is the smallest of such numbers. 13/07/09 My top 8 time-saving Firefox shortcuts This article presents my favorite top 8 time-saving shortcuts in Firefox 3.0 and Firefox 3.5. Get to know these and you'll be saving a lot of time. They have been ordered by "the element of most surprise" 20/05/09 Board Game Jungle speed / Arriba Review of the cool game "Jungle Speed" aka. "Arriba". 16/05/09 Danish Twin words "Twin words" are words that not only have multiple meanings, they must be composed next to each other in meaningful sentences. This article explores the concept of twin words. Nothing of interest? Try browsing the entire article archive... | |||||||||