The first tutorial will cover how to create a simple Java project that
includes compiling some source files, with some library dependencies, and
creating an output Jar file.
By introducing a simple first step, we can see how the different parts of
Antlion work together to make a more consise Ant build script.
The details of the source don't matter for our tutorial. Let's say that we've
developed an application that reads in an XML file, and outputs to STDOUT an
ASCII tree of the tag names.
To create the build scripts for our project, we'll follow the following
plan of attack:
- Layout of the Project
Before we begin to create our Ant scripts, we need to know how the
source files are arranged on the directory structure, and what kind of
project we're building. We'll also discuss where the 3rd party libraries
live, and what required resources we need.
- Add Antlion to the Build
When we create the
build.xml
file, the first thing we'll add
is the loading of the Antlion tasks.
- Describe What We're Building
Antlion likes to focus on what you're going to build, and we'll put that
inside a file called
artifacts.xml
, so that other projects can
easily reference what we've built.
- External Dependencies
We'll look at what it takes to compile the Java code, in particular how
we add libraries.
- Building the Code And Jars
We'll look at what it takes to compile the Java code based on the artifact
definition, and then bundling it up into jar files.
- Testing the Code
Like all good modern Java projects, we use JUnit to test our code. This
section shows how to setup the JUnit task to use the right classpath.
- Finishing Touches
Put the garnish on the build script so that it's a bit more user friendly.
This doesn't involve Antlion at all, but it's necessary for any build
script.
- Epilogue
A summary of what we learned, plus a side-by-side comparison between the
Antlion approach and the corresponding standard Ant build file.