CodeVisor's Blog

Visual Code Metrics & Analysis

Introduction to Ant and Build Systems

leave a comment »

What is a build system?

A build system is a piece of software that helps you build your project. Build doesn’t necessarily mean compile, there are many tasks associated with certain project, you may want to build a distributable package for example, package the current source code in a compressed archive, or you may want to build a PDF manual from documentation. The tasks you may need depends on the project and your requirements, but every task usually has some kind of a process that is repeatable every time you want to do that task.

Why use a build system?

A build system allows you to define steps needed to do what you want, which makes processing those repeatable tasks easy, less error-prune, time efficient, and more importantly unifies the process across different developers. A build system allows you to specify your dependencies clearly (i.e. To do C, you must do A and D first), and saves time by building files that was changed from the last build only.

Introduction to Ant

Ant is a cross-platform build system designed for Java software projects, although it can be used in other contexts, it’s widely used in Java projects. With Ant, you write an XML file, and then invoke ant with that file and other parameters to process the build.

For a software project, you will define targets. Targets are collections of tasks you want to do, common targets you will probably define are:

  • build to compile the source code using the javac compiler.
  • dist to build a distributable JAR file of the project, and maybe source code too if you want.
  • clean to delete compiled files and JAR files.

Those are just suggestions and to give you an idea of what targets are, but you can define the target to do whatever you want.

Steps within targets are executed by calling Ant Tasks. Removing a directory is a task for example that takes one parameter which is the directory to be removed. Ant provides a collection of predefined tasks, and you can write your own custom task in Java if those tasks don’t cover your needs, or isn’t available elsewhere.

Ant Example

This is an example build.xml file to show how Ant configurations look like: [1]

<?xml version="1.0" encoding="UTF-8"?>
<project name="ExampleProject">
<property name="src" location="src" />
<property name="build" location="build" />
<!--Defining a target named "build"-->
 <target name="build">
   <!--Create the build directory using the predefined "mkdir" Ant Task-->
   <mkdir dir="${build}"/>
   <!--Invoke the javac compiler to compile source code to the build directory-->
   <javac srcdir="${src}" destdir="${build}"/>
 </target>
 <!--A "clean" target to delete compiled files-->
 <target name="clean">
   <delete dir="${build}">
 </target>
</project>

To execute the build target in that example, you need to go to the command line, and switch to the directory where the XML file exists, then execute ant followed by the target name, in this case: ant build [2].

Ant assumes the file name is build.xml, if that’s not the case, you will have to pass the configuration file name as a parameter to ant (i.e. ant -f otherfile.xml).

Fortunately for those who don’t like the command line, as Ant is widely used, it’s integrated in many Integrated Development Environments like Eclipse, NetBeans and others.

Further Reading

Other Build Systems


Footnotes

[1] I’ve skipped introducing ant properties to keep it a short introduction, shouldn’t be hard to get though.
[2] This requires that you’ve already installed Ant of course.

Written by Hassan Ibraheem

25 February, 2010 at 11:52 am

Posted in Software

Tagged with ,

The Tools

leave a comment »

We have picked a set of tools that we’re going to use in our project, so I thought we would share those with you. For most of these tols, we tried the alternatives and tried experimenting with tools in the same category a little bit until we were comfortable with a single choice. All tools listed here are free and open source.

NetBeans Platform

We’re going to build our application on top of the NetBeans Plaform. NetBeans Platform prevents us from reinventing the wheel with providing common features used in many applications. We’re going to use most of those features extensively. Most notable features are modular design and window management. Learn More. We’re not planning to use NetBeans Platform anymore, due to steep learning curve, and other issues.

JavaCC

Java Compiler Compiler is a parser generator. It generates Java code that’s able to parse a language defined in a grammar file. We’re going to use JavaCC to build parsers to parse text files. JavaCC doesn’t have a runtime dependency, and it doesn’t need to be distributed with the executable application. Learn More

Prefuse

For 2D visualizations and graphs we’re going to use the Prefuse Java library. Prefuse is well-documented and easy to grasp quickly. While there are other easier solutions for dealing with graphs, we decided it’s worth it to eliminate an additional dependency and to use Prefuse for both 2D visualizations and graphs. Learn More

Processing

This one was introduced a little bit late, when we decided that we’re going to include 3D visualizations in CodeVisor. Processing is a great visualization tool. In my opinion, it’s not as simple as Prefuse, but it’s able to produce impressive visualizations indeed. Learn More, or take a look at some work produced by Processing.

Other Tools

Some tools exist for calculating different metrics, we’re going to explore some of those. If we find that integrating a tool would be easier than writing it from scratch, then we shouldn’t bother reinventing the wheel here too. In that case, patches and modifications to the original tool will be published (but not necessarily upstream).

This set may be expanded of course. At least one more tool will be added when we pick a subversion or git Java client to provide us with history and users information.

Written by Hassan Ibraheem

2 December, 2009 at 11:46 pm

Posted in General, Software

Hello World

leave a comment »

CodeVisor is the name of our graduation project. The full title is “CodeVisor: Visual Code Metrics and Analysis“.
Basically, the purpose of the project is to analyze software and provide useful visual information out of it.[1]

What do we mean by analyzing software?
We want to visualize many aspects of software that helps people understand software better, and visualize different software metrics that can help managers track development activity, and help developers spot possible problems and make better decisions.

Why this blog?
This isn’t my first blog, but I haven’t thought of dedicating a blog to our graduation project. However, this was motivated by the blog of another team. They’re doing a great job sharing their research and progress. So, we’ll try to share our progress here too. It doesn’t have to be about what we’re doing though, we may explore other related issues and applications that surround the project.


Footnotes
[1] In the meantime, we’re only focused on analyzing source code form of software, although this may be expanded later, we aren’t deciding on this now.

 

Written by Hassan Ibraheem

29 October, 2009 at 1:19 pm

Posted in General