Wednesday, September 24, 2008

Experience with Ant - Stack

Objective
  • The Ant build system
  • Open source Java automated quality assurance tools (FindBugs, Checkstyle, PMD)
  • The course standards for build system structure and packaging.

  • This assignment was my firs time to using ant to build a system. I have some experience with Make build tool for other classes, which was pretty difficult to use. During the studying for Ant, I learned that I can download and use open source Java automated quality assurance tools(QA tools) such as FindBugs, Checkstyle, PMD, and etc. Each automated QA tools have own purpose and tasks to the source files and these functions are very useful when we build a system.

    Installation
    In order to use Ant build tools with JUnit, PMD, FindBugs, Checkstyle, and Emma, we need to download each QA tools from sourceforge.net. Since the Ant tools does not like spaces in the directory name, is is recommended to unzip into a directory without spaces. After the unzip all files into correct directory, it requires users to define environmental variables for each QA tools. It took about 2 hours for me to make all environmental variables and classpath works correctly. After set up all installation and environmental, finally we can try to run ant build system with stack project. The given targets was following

  • ant clean compile
  • ant -f checkstyle.build.xml
  • ant -f dist.build.xml
  • ant -f findbugs.build.xml
  • ant -f javadoc.build.xml
  • ant -f junit.build.xml
  • ant -f pmd.build.xml
  • ant -f verify.build.xml

  • All of targets above was successful but the verify target was fail because the example provided contains few warnings with Checkstyle, JUnit, PMD, and FindBugs.

    Using Stack as a Template to create a new Project
    Create my own project from the provided example was pretty much straight forwarded and I did not encountered any problem during this step. The most important part of this step was that I edited the system.name property from "stack" to "stack-jeho" in the build.xml file.

    Fixing the problems in Stack so that "verify" target passes the build
    When I ran each QA tools for the stack project, it produced automated directories and report html files. All report html files were well organized and easy to read. It also displays the errors or warnings with correct source names and line number in the source file. To fix the problems that the original source has pretty easy. The most difficult part to fix was that fix the TestStack.java that has empty catch block because I did not know how to write a test that passes when an expected exception is thrown. After fixing all the problems reported by Checkstyle, JUnit, PMD, and FindBugs, I ran "ant -f verify.build.xml", which create a distribution zip file in the build directory. This file can be downloaded from here.

    No comments: