Ant - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Ant

Description:

make invokes makefile to automatically rebuild a program whenever one of the ... Apart from compilation, make is an effective tool for program installation and ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 12
Provided by: cise8
Category:
Tags: ant | make

less

Transcript and Presenter's Notes

Title: Ant


1
Ant Eclipse
  • CEN3031 Software Engineering

2
Ant make utility
  • Ant
  • Operating system independent java-based make
    utility
  • make
  • UNIX utility which allows you to manage large
    programs or groups of programs.
  • makefile
  • Describes the relationship among source files and
    provides commands for updating each file.
  • make invokes makefile to automatically rebuild a
    program whenever one of the source files is
    modified.
  • All files dependent on any of modified files are
    also rebuilt.
  • Apart from compilation, make is an effective tool
    for program installation and system configuration
    changes.

3
Ant General
  • Ant's buildfiles are written in XML.
  • XML Extensible Markup Language
  • Markup Language a language such as HTML and XML
    that use tags (Markups) to format the Content of
    documents.
  • The buildfile is named build.xml by default
  • Each buildfile contains one project and at least
    one (default) target.
  • Each project defines one or more targets.
  • A target is a set of tasks you want to be
    executed.

4
Ant General (Cont.)
  • Project
  • Three attributes name, default, basedir
  • Targets
  • Specifies a set of tasks you want to have run
  • A target can depend on other targets
  • Use depends attribute to specify dependencies
  • depends attribute specifies the order in which
    targets should be executed
  • Tasks
  • A piece of code that can be executed
  • Built-in tasks mkdir, delete, zip, etc
  • Optional tasks image, sound, junit, telet, etc
  • You can also write your own task
  • Properties
  • A property has a name and a value

5
Working With Ant
  • Create Project File -gt New -gt Project -gt Java
    Project -gt Name it, HelloAnt
  • Create class File -gt New -gt Class -gtName it,
    HelloAnt
  • Inside of the main() method add following
  • System.out.println(Hello Ant Example)
  • Crate another class File -gt New -gt Class -gtName
    it, HelloAnt2
  • Inside of the main() method add following
  • System.out.println(Hello Another Ant Example)
  • To work with Ant, we'll need an Ant buildfile
    which is named build.xml by default.
  • Right click the project -gt New -gt Name it,
    build.xml -gt finish
  • Eclipse recognizes that build.xml is an Ant build
    file, and marks it with an ant icon.

6
Ant buildfile
  • What we will do in our Ant buildfile are
  • Initialize (clean up, create directories)
  • compiles my stuff
  • make the jar, so that I can deploy it
  • We will have targets of following
  • lttarget name"Main Build" depends"Initialize,
    Jar, Compile"gt
  • lttarget name"Initialize"gt
  • lttarget name"Compile" depends"Initialize"gt
  • lttarget name"Jar" depends"Initialize, Compile"gt

7
Sample build.xml
  • lt?xml version"1.0" encoding"UTF-8" ?gt
  • ltproject name"HelloAnt" default"Main Build"
    basedir"."gt
  • ltproperty name"bin" location"bin" /gt
  •   ltproperty name"src" location"src" /gt
  •   ltproperty name"jardir" location"bin/lib"
    /gt
  •   ltproperty name"jarfile" location"jardir/H
    elloAnt.jar" /gt
  • lttarget name"Main Build" depends"Initialize,
    Jar, Compile"gt
  • ltecho message"Ant at work!" /gt
  • lt/targetgt

8
Sample build.xml (Cont.)
  • lttarget name"Initialize"gt
  • ltdelete dir"bin" /gt
  •   ltdelete dir"jardir" /gt
  • ltmkdir dir"bin" /gt
  •   ltmkdir dir"jardir" /gt
  • lt/targetgt
  • lttarget name"Compile" depends"Initialize"gt
  •   ltjavac srcdir"src" destdir"bin" /gt
  • lt/targetgt
  • lttarget name"Jar" depends"Initialize,
    Compile"gt
  •   ltjar destfile"jarfile" basedir"bin" /gt
  • lt/targetgt
  • lt/projectgt
  • Execution order Initialize -gt Compile -gt Jar -gt
    Main Build

9
Run Ant
  • Right Click build.xml -gt Run As -gt Ant Build
  • Let's take a look the result of running the
    build.xml
  • /bin/lib/ directories created under /HelloAnt/
  • HelloAnt.class, HelloAnt2.class created under
    /HelloAnt/bin/
  • HelloAnt.jar created under /HelloAnt/bin/lib/
  • Run selective targets Right click on the target
    name from Ant View -gt Run As -gt Ant Build

10
References
  • Apache Ant 1.6.2 Manual
  • http//ant.apache.org/manual/index.html
  • Introduction to Eclipse, CVS, Tomcat, and ANT
  • http//smweb.bcgsc.bc.ca/cbw/dtt2004.html
  • Building Eclipse Projects Usint Ant
  • http//www.onjava.com/onjava/2004/02/04/AntEclipse
    .pdf

11
Sourceforge submission
  • Visit
  • http//sf0.cise.ufl.edu8080/sf/sfmain/do/home
  • Logon to Sourceforge with your ID and password
  • Click on Project tab
  • Click on your project
  • Click on Documents tab
  • Click on Create button located at your bottom
    right
  • Browse to your zipped (tarred) file and click on
    Save
Write a Comment
User Comments (0)
About PowerShow.com