COMP220: Software Development Tools

Lab 4-5

Please, from now on (until explicitly required), AVOID using Ecpilse!!

The point is that working jointly with Eclipse and Ant without experience may be overcomplicated and may serve as a source of possible mistakes.

Ant: Structured Build

Please, follow slides Ant: Structured Build.

Start with creating the directory

 
H:\Antbook\ch02\secondbuild
 

which will serve in this Lab as as current directory or base directory.

Create also subdirectories src and build\classes according to the slide 6.

Continue reading these slides making step-by-step all actions required there. These actions are typically labelled by the word TRY or RUN or in other way by using red colour. Do not hurry up! Achieve the full understanding of all the comments in slides.

This may take a longer time. Please finish it yourself. This way you will get a good understanding of the initial concepts of Ant.


Optional material (Self-Study). At the end of the above portion of work (see Slides 43-46) you will need the extended file build.xml. Save it in your secondbuild directory (Right-Click -> Save-Link-As...; It is a wrong idea to open an XML file by a browser and then copy-and-paste it into an editor window!).


Ant: Working with filesets

Please, follow slides Ant: Datatypes and Properties.

First, read and understand Slides 1-20 and do exercises from Slides 20-22. You will continue working in

 
C:\Antbook\ch02\secondbuild

possibly creating appropriate new files and subdirectories.

Please do not change already existing files for future revision of your work. You only can delete directories build and dist which are easily recoverable with their content by running in the above directory the command

ant -f structured.xml

It makes sense to create one build file (call it, say, filesets.xml) to work in it with various filesets. Additionally, experiment with a bit more complicated (than in lectures) filesets having several <include> and <exclude> elements

In fact, it is assumed that you will be creative enough to do these simple exercises. For example, you could generate several ditectories and subdirectories and some artificial files in them with various extensions (just create a text file and change its extension in any way you need) to experiment with <include> and <exclude> elements.

Additionally, create in your build file filesets.xml some complicated fileset with an id, and then copy this fileset by using the attribute refid to simplify the form of the <copy> task. (See Slides 4,5 with examples on using id and refid attributes.)

You can invent your own experiments to check that Ant really does things described in slides considered in lectures.

Note that all of this gives you the best chance to prepare to the exam.


All of you will be working on your Third Year Projects, probably writing your code in Java. Is anything from what we studied about Ant really useful for you?

Of course, there is some inertia preventing you from using the new tool. There was considered not so much of useful Ant tasks yet in our lectures. You can, at least, imagine in which future situation you would start using Ant in practice. At first, it will help you just a little, say, only compiling and running your application. Even this very simple using of Ant will actually save your time. (One hit on "Enter" key insted of running two commands, and doing this many times a day!) Later on you would probably include some more Ant tasks into your repertoire... Just start getting at least anything useful from Ant for your projects. Later on you could start using JUnit testing (also in the framework of Ant).


Ant: Working with properties

Please, follow slides Datatypes and Properties and the following instructions.

1. Built-in properties

·          
·         H:\Antbook\ch02\secondbuild\builtinprop.xml

which will serve to check various built-in properties of Ant and JVM system properties from Slides 4-9. Check also the behaviour of basedir depending on how it is declared in this build file or in command line (Slides 7,8).

2. Setting and using properties by the tasks <property> and <available> (and also <uptodate> and <condition> - to be considered later).

·          
·         H:\Antbook\ch02\secondbuild\available.xml

(with several appropriate targets) in the old directory which already contains the necessary subdirectories and files there.

Important experiment with JAR files

When running structured.xml build file, you created project.jar file. Rename its extension .jar with .zip and click on this file to see what is inside. Which files from build/classes are archived there? Under which system of subdirectories? Compare this with the content of the archived directory build/classes. (For simplicity, we ignore META-INF in this comparison.)