Sponsors

Microsoft


TechWell

We have 2936 guests and 5 members online

Home CM Basics Building your java application

Building your java application

E-mail
Written by Bob Aiello   
Monday, 31 March 2008 17:49
baapr08-basicsbuildingBuild engineering is an important part of being a good CM practitioner.  It is important to learn and be familiar with the popular build tools that are available.

Ant has long been the most common tool for building java applications. (In a future article we will talk about Maven, which is another java build tool.) Ant is "procedural" - which means that you must spell out exactly what needs to be done. In this case we want to create our BigJavaProgram.  In the first step ("compile") we compile the java source into classes. The next step ("dist") we take the classes and bind them into the jar which is placed into the ${dist}/lib.

The default target is set to "dist" which depends upon "compile", which in turn depends upon "init". The "init" step creates the build directory. Ant is pretty, although a little hard to read at first.

You can run this simple example by typing "ant". To clean up the previous release you would type "ant clean".

What kind of ant build questions do you have?  Send them to me and we'll print the answer in an upcoming issue!  You can also find simple examples like the one below from http://ant.apache.org.

<project name="BigJavaProgram" default="dist" basedir=".">

  <!- This is the way that you add a comment -->
  <description>
        This is where you write a description of your build.
  </description>

  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>

  <target name="init">
    <!-- Create the a build directory -->
    <mkdir dir="${build}"/>
  </target>
 
  <target name="compile" depends="init"
        description="compile the java source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}"/>
  </target>

  <target name="dist" depends="compile"
        description="generate the distribution" >

    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib"/>
    <jar jarfile="${dist}/lib/BigJavaProgram.jar" basedir="${build}"/>
  </target>
 
  <!-clean the directories from the last build à
  <target name="clean">
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>

</project>


Bob Aiello is the Editor-in-Chief for CM Crossroads and an independent consultant specializing in Software Process Improvement including Software Configuration and Release Management. Mr. Aiello has over 25 years experience as a technical manager in several top NYC Financial Services firms where he had had company-wide responsibility for CM, often providing hands-on technical support for enterprise Source Code Management tools, SOX/Cobit compliance, build engineering, continuous integration and automated application deployment. Bob is a long standing member of the Steering Committee of the NYC Software Process Improvement Network (CitySPIN), where he serves as the chair of the CM SIG. Mr. Aiello holds a Masters in Industrial Psychology from NYU and a B.S. in Computer Science and Math from Hofstra University. You may contact Mr. Aiello at raiello@acm.org  or link with him at http://www.linkedin.com/in/bobaiello .

Trackback(0)

Comments (0)add comment


Write comment

You must be logged in to post a comment. Please register if you do not have an account yet.

busy
Last Updated on Saturday, 12 April 2008 18:58
 
509 Bandwidth Limit Exceeded

Bandwidth Limit Exceeded

The server is temporarily unable to service your request due to the site owner reaching his/her bandwidth limit. Please try again later.