Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to Ant. What is Ant? How do you use it? Why would you want to?

Similar presentations


Presentation on theme: "An Introduction to Ant. What is Ant? How do you use it? Why would you want to?"— Presentation transcript:

1 An Introduction to Ant

2 What is Ant? How do you use it? Why would you want to?

3 What is Ant? According to Ant’s web site, ant is “ Apache Ant is a Java-based build tool. In theory, it is kind of like Make, but without Make's wrinkles.” I’ve called Ant “Make on Steroids!” Originally written as a tool to build Tomcat, but has EVOLVED!

4 Make / Script (Shell/Batch) Limitations Shell-based: tied to a particular OS Makefile issues: tab vs. space Poor integration with external tools Can be difficult to read Multiple dialects

5 Ant Advantages Platform independent XML config files Tasks run by object implementing Task Interface Easy to configure (properties / parameters) Good integration with other tools (Eclipse, JUnit, CruiseControl, etc)

6 How to use Ant Install Ant –Get It from the Ant home page –Install It –(Optional) Build It –Check Library Dependancies and Platform- dependant issues

7 How to Use Ant Configured using an XML buildfile Buildfile contains one project and at least one target Targets contain Tasks

8 Ant Buildfile Projects have three attributes –Optional name - name of project –Required default - task to perform –Optional basedir - base directory used for path calculation

9 Ant Buildfile A project defines one or more targets A target is a set of tasks to execute The default target is executed unless a target is specified when executing Ant

10 Ant Buildfile - Target

11 Ant Buildfile - Targets Can depend on other targets Gets executed only once Can determine execution based on a property

12 Ant Buildfile - Tasks Code that can be executed Can have multiple attributes Ant includes built-in tasks and optional tasks Can write your own tasks in Java

13 Ant Buildfile - Properties Properties can be set for a project Setup using the task Setup in an external properties file Case-sensitive name / value Can be reference in task attributes using “${propertyName}” System properties and Ant built-in properties available

14 Ant Buildfile - Properties <!-- set environment specific properties for this build environment defaults to dev but should be overridden on command line: -Denv=prod -->

15 Ant Buildfile - PatternSets Patterns can be grouped in sets and referenced by id Defined by element –nested in a FileSet –directory-based task –stand alone element at target level

16 Ant Buildfile - PatternSets has the following attributes: –includes: list of patterns/files to include –includesfile: name of file listing includes –excludes: list of patterns/files to exclude –excludesfile: name of file listing excludes Can also use nested and elements to specify patterns

17 Ant Buildfile - FileSets Groups of files Used by many tasks Files are found in a directory tree starting in a base directory and matching any number of PatternSets Can use nested elements Also holds an implicit PatternSet

18 Ant Buildfile - FileSets <fileset dir="${build}" includesfile=“readme.txt"/> <fileset dir="${lib}/resources" includes="**/JTF.properties"/>

19 Ant Buildfile – Token Filters Automatically expanded if filtering is used when copying files Can be specified globally or within specific copy tasks Should only be used with text files NOT BINARY

20 Ant Buildfile – Token Filters

21 Ant Buildfile – Token Filters <copy todir="${dist}/${env}/jtf/properties" file="${src}/log4j.properties" preservelastmodified="true"> <filter token="LOG4J_WEBAPP_DIR" value="${log4j.webapp.dir}"/> <filter token="LOG4J_SERVLET_LOG_LEVEL" value="${log4j.servlet.log.level}"/> <filter token="LOG4J_TIMING_LOG_LEVEL" value="${log4j.timing.log.level}"/>

22 Why Use Ant? Ease of Use/Configuration Extensible Standardized Integrated with other tools Platform Independent It’s Java It’s Open Source

23 Ant Resources Ant home page http://ant.apache.org/ Ant User Manual http://ant.apache.org/manual/index.html Ant Resources http://ant.apache.org/resources.html “Ant in Anger” http://ant.apache.org/ant_in_anger.html

24 Ant Resources Ant: The Definitive Guide Tilly & Burke, O’Reilly Ant Developer’s Handbook Williamson, et. Al., Sams Ant Developer’s Guide http://bis.cit.cornell.edu/internal/twiki/bin/view/Know /AntDevelopersGuide


Download ppt "An Introduction to Ant. What is Ant? How do you use it? Why would you want to?"

Similar presentations


Ads by Google