MC365 Ant - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

MC365 Ant

Description:

Apache Ant is a Java-based build tool. ... like tools are inherently shell-based -- they evaluate a set of dependencies, ... http://ant.apache.org/bindownload.cgi ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 11
Provided by: brianb99
Category:
Tags: ant | apachebased | mc365

less

Transcript and Presenter's Notes

Title: MC365 Ant


1
MC365Ant
2
Today We Will Cover
  • Overview of Ant
  • Installing Ant
  • Using the Ant command line tool
  • Various Ant commands available
  • Using Ant in Eclipse

3
Overview of Ant
  • Ant is an open source tool that is part of the
    Jakarta project
  • It is a build/deployment tool.
  • What is a build/deployment tool?
  • Once you have finished coding your web
    application (including servlets, jsps, html,
    gifs, etc), you need to compile and move (or
    deploy) these components to various destinations
    before you can use them.
  • For example, you need to compile and deploy your
    servlets to the classes folder in Tomcat and your
    jsps to your jsp folder
  • With a large web application containing many
    components, this can get complicated.
  • Also, you may want to deploy to multiple servers
    (for load balanced systems, or for test/QA
    systems, etc).

4
Overview of Ant
  • Apache Ant is a Java-based build tool. In theory,
    it is kind of like Make, but without many of
    Make's problems.
  • Why another build tool when there is already
    make, gnumake, nmake, jam, and others?
  • Because all those tools have limitations when
    developing software across multiple platforms.
  • Make-like tools are inherently shell-based --
    they evaluate a set of dependencies, then execute
    commands not unlike what you would issue in a
    shell.
  • This means that you can easily extend these tools
    by using or writing any program for the OS that
    you are working on.
  • However, this also means that you limit yourself
    to the OS, or at least the OS type such as Unix,
    that you are working on.

5
Overview of Ant
  • More reasons to choose Ant over Make
  • Makefiles are much mjore difficult to use. Make
    is notorious for not working due to simple
    formatting errors like having a space in front of
    a tab
  • Ant is different. Instead of a model where it is
    extended with shell-based commands, Ant is
    extended using Java classes.
  • Instead of writing shell commands, the
    configuration files are XML-based, calling out a
    target tree where various tasks get executed.
    Each task is run by an object that implements a
    particular Task interface.
  • Granted, this removes some of the expressive
    power that is inherent by being able to construct
    a shell command such as find . -name foo -exec
    rm , but it gives you the ability to be cross
    platform -- to work anywhere and everywhere.
  • And if you really need to execute a shell
    command, Ant has an ltexecgt task that allows
    different commands to be executed based on the OS
    that it is executing on.

6
Installing Ant
  • To install Ant go tohttp//ant.apache.org/bindow
    nload.cgi
  • Click on the link to download the zip archive if
    you are using Windows.
  • Save it to your hard drive and unzip into a
    folder you create (e.g. c\ant).
  • Add the ant\bin lib to your system Path variable.
  • Set the ANT_HOME variable to the directory where
    you installed Ant
  • Set the JAVA_HOME variable to where your jdk is
    installed
  • Assume Ant is installed in c\ant\. The following
    sets up the environment
  • set ANT_HOMEc\ant\jakarta-ant-1.5.2
  • set JAVA_HOMEc\j2sdk1.4.1_01
  • set PATHPATHANT_HOME\bin

7
Using the Ant Command Line Tool
  • Once you have installed Ant, you are ready to set
    up your deployment specifications for your web
    application.
  • To do this you need to create a build.xml file
    for your application.
  • Each application will probably have its own
    build.xml file.
  • Click here to see an example of a simple
    build.xml file.
  • To execute the build.xml file, simply call type
    ant in that directory
  • Or type ant target1 target2
  • Go to http//ant.apache.org/manual/index.html and
    click on Running Ant to see various ant command
    options.

8
Various Ant Commands Available
  • Ant is a very powerful tool that can do many
    things.
  • Again, we could spend an entire semester talking
    about the various Ant tasks. In fact, there are
    people who do this full-time. They are called
    build engineers.
  • As Software Engineers, you should be familiar
    with the basic functionality of Ant.
  • It will also make development a lot easier.
  • Read the documentation on this site for extensive
    information on Ant. There is some great
    information under the Manual link under
    Documentation.
  • For a list of Ant tasks go to http//ant.apache.or
    g/manual/index.html and click on Ant Tasks.

9
Using Ant in Eclipse
  • Like CVS, Eclipse allows developers to write
    their build.xml files and execute them from
    within the IDE making development a lot easier.
  • To define the classpath, go to Window-Preferences
    and click on External Tools-Ant-Classpath
  • The basic jars you need to run Ant should already
    be there.
  • You can import/export/work on a build.xml file
    just like any other file in Eclipse.

10
Using Ant in Eclipse
  • To run the build.xml for an application, go to
    Run-External Tools-Configure.
  • Click New
  • Give it a name
  • For Tool Location, click Browse Workspace and
    find the build.xml
  • For Tool Arguments, click Browse Variables,
    highlight Ant Targets and select the targets you
    want
  • Click Ok
  • Then go back to Run and choose the name you gave
    your configuration.
Write a Comment
User Comments (0)
About PowerShow.com