Showing posts with label ANT. Show all posts
Showing posts with label ANT. Show all posts

Thursday, April 5, 2012

Ant script to replace tokens (VERSION) in a file (build.properties)

Version of a product ever changes for main releases, SP releases, hotfix releases, etc. We can't hard-code version value in source files. One of the effective solution to tackle this is to use tokens in the place of version values and replace it before the start of build. The most common tool used to make string replacements are scripts written in perl/shell. Though scripts works well, but why to depend on scripts which are closely tied with Unix systems, to perform token replacement operations on platform independent Java build systems. 


 Java builds are usually managed through Ant/Maven. If perl/shell scripts are not stored along with Java build system, then if anyone checkouts only java code from source control, there build may fail due to improper version characters.


Here is an illustration of performing token replacement using Ant script.

Thursday, January 21, 2010

Visual representation of Ant target dependencies using tool Grand

Is your ant build file is more than 500 lines? Is your ant build file contains hundred's of targets? Then there is no doubt that you will definitely get lost in the process of understanding it. Fortunately there are tools which graphically represents Ant target dependencies. One such tool I recently used is Grand.

You can download Grand from http://www.ggtools.net/grand/. For windows, download grand-ui.zip file and extract it.
Then double click on grand-ui.bat, which opens up an editor. From the editor, open your ANT build file through File menu (File -> Quick open). Then it generates graph of all the target dependencies. It also identifies default target in different color (yellow). If a target (represented in oval )is clicked, it displays the code for that target in bottom frame.
Another good thing is that it also traverse targets present in the build files which are imported by parent build file.

This tool emphatically helps to understand complex Ant build files