Learn ANT Build tool

22
Ant Build Tools

description

Prepared by DON McGREGOR. I downloaded it from Google and liked it very much . Hope you like it too.

Transcript of Learn ANT Build tool

AntBuild Tools

Build Tools Creating a product from source may take several steps: Compile Link Copy files to various directories Remove intermediate files Generate documentation It becomes problematic to do all these steps manually, first of all because its boring, second because it is error-prone. The objective should be an automated tool that does all the work for you. Type or click one command and create a final product.

Build Tools There are a couple ways this can be done: Write a batch file or script The scripts tend to be hard to maintain

Use a tool designed for the task Make Ant

Make Make is the original tool for this sort of thing. Roots in the Unix world The stuff to the left of the colon is the target, the stuff to the right the dependents, and the lines below that the actions to take If a target is newer than its dependents, the actions are performedlib.a: x.o y.o z.o ar rvu lib.a x.o y.o z.o ranlib lib.a

Make Make has some well-known pathologies The action lines MUST start with a tab, which is impossible to see The action lines have platformdependent scripting dependencies

Ant The platform restrictions werent so bad in the Unix world, but Java was intended to be cross-platform. A build file using Make couldnt transition from a Unix to a windows box to a Mac box. Make tends to be C- and Unix-centric. So ant was developed as a crossplatform build tool

What File Format to use? If youre developing a new tool, what should the syntax of the file be? The world needs fewer file formats. If you write your own unique syntax, like Make files, you wind up having to parse that syntax. That usually means a trip to yacc, lex, and friends. Ant choose to use XML rather than develop its own syntax. This lets people leverage their existing knowledge of XML rather than learn a bunch of new rules

Ant Ant is a cross-platform, XML-based system for creating software products from source code. It is NOT a scripting language. But that doesnt stop some people. Open source, available at www.apache.org

Installing Ant Get the binary release and set ANT_HOME and JAVA_HOME environment variables. Put the ant bin directory on the PATH environment variable.

Example Fragment Creates some directories to hold the output of the build process. Matching and tags Solo tags ended with /> Uses XML tag attributes