Category Archives: Apache Ant

Installing ANT on Ubuntu

Hi All,

Installing ANT on Ubuntu is fairly very simple. All We have to do is to open the terminal window. And simply run the below command.

sudo apt-get -u install ant

Once you run the command You will be prompted for the admin password and the installation begin.. Once Done simply type ANT in the terminal..

Hope this Helps.

R Vashi

Use main ant build file call sub build file

Hi All,

In this article I will explain how to call the sub build.xml files. Whenever we have bigger project code base then it is always very much required to have small build script files. For example for Code review reports we can go for separate build script files, and we can invoke this script file from the main build script file. This will give ease in maintaining the build scripts and ease to read.

To invoke a sub build script file simply make the below call.

<target name="startBuild" description="Build the project" depends="someOtherRequiredStepTask">
<!-- Here we will call the sub build script file -->
<!-- If you want to pass on the same environment(properties) to the sub file set inheritall="true" -->

<antfile="/module1/build.xml" inheritall="false">

H T H.

R Vashi

Timestamp using ANT

Hi All,

In this article I will show how to create a Timestamp using ANT script, Timestamps are very helpful when we are creating daily code review reports, war/ear files, as we can simply append the timestamp with file name which gives us the ease of identifying the file creation date & time.

When we execute <tstamp/>, it generates the local ANT macros ${TSTAMP} and ${DSTAMP}. These are the time and date as numeric strings. They can then be used to dynamically generate timestamp strings.

The below is an example of using time stamp on Jar file creation:

<jar jarfile=”${jar}-${DSTAMP}${TSTAMP}.jar” compress=”true”> …. </jar>

TSTAMP – sets the DSTAMP, TSTAMP, and TODAY properties in the current project.

[NOTE]  By default, the DSTAMP property is in the format “yyyyMMdd”, TSTAMP is in the format “hhmm”, and TODAY is in the format “MMMM dd yyyy”.

Hope this helps.

R Vashi

Jar scanner for finding jars

Hi All,

I am very happy to share a tool written by me, I have named it Archive Scanner, As the name suggest this tool will help to search for Java classes jar names. Sometime we spend lots of time searching for a jar name, and looking here and there. I can understand this pain as I have faced so many times. So it is a sort of tool I have gifted to myself and all you out there.

This tool(jar) is self executable, only things is that you need to set up a java environment to use that.
It works on JDK.1.5 or later. Please download from the below file.

Tool DownLoad:
archive scanner

Steps to Use:
– First of all save the Jar it to some location. e.g c:\myTool
– Open command Console and change the directory to the location where Jar has been saved
– Set Java Home (ignore if already defined)

– Run the below java command
– java -jar <<Name of jar>> –searchType DSF –dirName C:\\bea\\modules\\ –fileName Classwriter.class
– java -jar <<Name of jar>> –searchType DSF –dirName C:\\bea\\modules\\ –fileName Classwriter
– java -jar <<Name of jar>> –searchType DSF –dirName C:\\bea\\modules\\ –fileName com/bea/objectweb/asm/ClassWriter
– java -jar <<Name of jar>> –searchType DSF –dirName C:\\bea\\modules\\ –fileName com.bea.objectweb.asm.ClassWriter
– java -jar <<Name of jar>> –searchType DSF –dirName C:\\bea\\modules\\ –fileName com.bea.objectweb.asm.ClassWriter.class

Hope this help, Please give your suggestions or your experience with this tool, this would help me to apply any sort of improvements further.

Happy learning.

R Vashi

Using Flex PMD for Flex Code Review using ANT

Hi All,

Adobe Technical Services launched FlexPMD – a tool to audit  ActionScript source code and detect common problems (anti patterns, unused code, badly written Flex components ). The tool started as an internal project in Adobe and now it has been made open source.

I can say that using this tool is a must for any complex Flex projects, because it enables you to detect common problems at an early phase. For the moment it can be invoked from Maven/Ant and Mac OS X automaton, in the future it will probably also be available as a Flash Builder plugin.

Below I will detailed out how to use this with ANT script, to get a report.

Step 1: Download the required jars.

Step 2: Copy the jars in Lib folder e.g  c:\myproject\lib

Step 3: Write an ant script and add those jars into Classpath.

Flex PMD example
<mkdir dir=”${basedir}/flex/” />
<mkdir dir=”${basedir}/bin1/” />
<property name=”src.dir” value=”${basedir}/flex/” />
bin1/” />

<property name=”flexpmd.version” value=”1.1″ />
<property name=”flexpmd.dir” value=”jars/flex-pmd-ant-task-1.1/” />


<taskdef name=”flexPmd”
<pathelement location=”${flexpmd.dir}/flex-pmd-ruleset-api-1.1.jar”/>
<pathelement location=”${flexpmd.dir}/flex-pmd-ruleset-1.1.jar”/>
<pathelement location=”${flexpmd.dir}/flex-pmd-core-1.1.jar”/>
<pathelement location=”${flexpmd.dir}/as3-plugin-utils-1.1.jar”/>
<pathelement location=”${flexpmd.dir}/as3-parser-api-1.1.jar”/>
<pathelement location=”${flexpmd.dir}/pmd-4.2.5.jar”/>
<pathelement location=”${flexpmd.dir}/commons-lang-2.4.jar”/>
<pathelement location=”${flexpmd.dir}/flex-pmd-files-1.1.jar”/>
<pathelement location=”${flexpmd.dir}/plexus-utils-1.0.2.jar”/>

<target name=”flexPmdWithCustomRuleset”>


Step 4: Run the ant scripts  e.g  >ant flexPmdWithDefaultRuleset

Step 5: After running the ant task, you will see the task output details on the Console.

[flexPmd] 01-Jun-2010 20:34:09 loadRuleset
[flexPmd] INFO: Ruleset: c:\DOCUME~1\603\LOCALS~1\Temp\default_flex5303689465491432723.xml
[flexPmd] 01-Jun-2010 20:34:09 loadRuleset
[flexPmd] INFO: Rules number in the ruleSet: 90
[flexPmd] 01-Jun-2010 20:35:01 computeViolations
[flexPmd] INFO: It took 51497ms to compute violations
[flexPmd] 01-Jun-2010 20:35:01 computeViolationNumber
[flexPmd] INFO: Violations number found: 3256
[flexPmd] 01-Jun-2010 20:35:01 writeReport
[flexPmd] INFO: Creating report in
[flexPmd] 01-Jun-2010 20:35:01 writeAnyReport
[flexPmd] INFO: It took 390ms to write the Xml report

The main things is that it works well on MXML files. Covers all the action script code written.

Also we can easily transform it to some HTML Report by using XSL. Simply give the path of generated report and path of XSL and the location of HTML report.

<xslt in=”${bin.dir}/pmd.xml” style=”pmd-nicerhtml.xsl” out=”bin1/pmd.html” />
Tip: XSL can be found inside pmd-4.2.5.jar, etc folder

R Vashi

java.lang.OutOfMemoryError: PermGen space

Hi All,

Few days back I was reading one of the article of my all time favorite guru(Jaysen sharma), So I would like to share that in this article.

In case of OutOfMemoryError in PermGen Sapace …increasing only the Heap Size will not solve anything…


(OS Level)Process Size = Java Heap Native Space (2-3% OS related Memory)

PermSize : It’s a Native Memory Area Outside of the Heap, Where ClassLoading kind of things happens…. In an operating System like Windows Default Process Size is 2GB (2048MB) default (It doesn’t matter How much RAM do u have 2GB or 4GB or more)…until we don’t change it by setting OS level parameter to increase the process size..Usually in OS like Solaris/Linux we get 4GB process size as well.

Now Lets take the default Process Size=2GB (Windows), Now if you have set the -Xmx512M, we can assume that rest of the memory 1536 Mb is available for Native codes.

(ProcessSize (-) HeapSize) = Native (+) (2-3% OS related Memory)

2048 MB (-) 512 MB = 1536 MB


MaxPermSize = (Xmx/3) —- Very Special Cases (One Third of maximum Heap Size)

MaxPermSize = (Xmx/4) —- Recommended (One Fourth Of maximum Heap Size)

So finally you need to increase the PermGen Size… like -Xmx1024m -Xms1024m -XX:MaxPermSize256m

But again these are not the Final values … It depends on ther Environments


R Vashi.

Using Checkstyle with ANT for JAVA Code review

Hi All,

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.

Step 1: Download Checkstyle jar from

Step 2: Place the checkstyle jars into the Lib directory of your project.

Step 3: Write a build script and add the below ANT Task for running Checkstyle code reviews. Initially Checkstyle generates a XML report for code reviews. So we can use XSL Stylesheet to transform that in HTML format.(see inside the task)

<target name=”runCodeReview”>

config = “${basedir}/lib/checkstyle_allchecks.xml” classpathref=”build.classpath”  failOnViolation=”false” >
<fileset dir=”${basedir}/src” includes=”**/*.java”/>
<!– fromatter is used to generate a XML file –>

<xslt in=”${basedir}/reports/code-cs.xml” out=”${basedir}/reports/java_checkstyle_report.html”     style=”${basedir}/checkstyle.xsl”/>
<!– we can use XSL stylesheet to transform the XML reports into HTML format –>

NOTE: Sometime it is not feasible to use all the JLS coding standards, due to project coding standards requirement, For this we can easily customize few rules in checkstyle_allchecks.xml.

R Vashi