An Introduction to Ant Bryan G. Hutchinson preEmptive Solutions, Inc.
An Introduction to Ant What is Ant? How do you use it? Why would you want to?
What is Ant? “crawling insect living in colonies: an insect that lives in complex well-organized colonies and is noted for …” Encarta World English Dictionary
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!”
Make Limitations Shell-based: tied to a particular OS Makefile issues: tab vs. space
Ant Advantages Platform independent - thanks to Java! XML config files Tasks run by object implementing Task Interface
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
How to Use Ant Configured using an XML buildfile Buildfile contains one  project  and at least one  target Targets  contain  Tasks
Ant Buildfile Projects  have three attributes Optional name - name of project Required default - task to perform Optional basedir - base directory used for path calculation <project name=”JavaSig&quot; default=&quot;deploy&quot; basedir=&quot;.&quot;>
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
Ant Buildfile - Target <target name=&quot;deploy&quot; depends=&quot;dist&quot;> <!-- Copy jars to the weblogic instance --> <copy preservelastmodified=&quot;yes&quot;    todir=&quot;${deploy_dir}&quot;> <fileset dir=&quot;${dist}&quot;> <include name=&quot;*.jar&quot;/> <exclude name=”TestClients.jar&quot;/> </fileset> </copy> </target>
Ant Buildfile - Targets Can depend on other targets Gets executed only once Can determine execution based on a property
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  <javac srcdir=&quot;${src}&quot; destdir=&quot;${build}&quot;> <classpath refid=”compile.class.path&quot;/> </javac>
Ant Buildfile - Properties Properties can be set for a project Setup using the <property> 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
Ant Buildfile - Properties <!-- set global properties for this build --> <property name=&quot;src&quot; value=&quot;src&quot;/> <property name=&quot;build&quot; value=&quot;build&quot;/> <property name=&quot;dist&quot; value=&quot;dist&quot;/> <property name=&quot;lib&quot; value=&quot;lib&quot;/> <property name=&quot;archive&quot; value=&quot;archive&quot;/> <property name=&quot;weblogic.home&quot; value=&quot;c:\weblogic&quot;/> <property name=&quot;wl_lib&quot; value=&quot;${weblogic.home}/myserver/lib&quot;/>
Ant Buildfile - PatternSets Patterns can be grouped in sets and referenced by id Defined by <patternset> element nested in a FileSet directory-based task stand alone element at target level
Ant Buildfile - PatternSets <patternset> 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 <include> and <exclude> elements to specify patterns
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 <patternset> elements Also holds an implicit PatternSet
Ant Buildfile - FileSets <fileset dir=&quot;${build}&quot; includesfile=&quot;browseQueues.txt&quot;/> <fileset dir=&quot;${lib}/resources&quot; includes=&quot;**/BrowseQueues.properties&quot;/> <fileset dir=&quot;${dist}&quot;> <include name=&quot;*.jar&quot;/> <exclude name=&quot;GrinderTests.jar&quot;/> <exclude name=&quot;SystemTest.jar&quot;/> <exclude name=&quot;BrowseQueues.jar&quot;/> </fileset>
Why Use Ant? Ease of Use/Configuration Extensibility Standardized Platform Independent It’s Java It’s Open Source
Ant Resources Ant home page http://jakarta.apache.org/ant/index.html Ant User Manual http://jakarta.apache.org/ant/manual/index.html Ant Resources http://jakarta.apache.org/ant/resources.html “ Ant in Anger” http://jakarta.apache.org/ant/ant_in_anger.html

Ant

  • 1.
    An Introduction toAnt Bryan G. Hutchinson preEmptive Solutions, Inc.
  • 2.
    An Introduction toAnt What is Ant? How do you use it? Why would you want to?
  • 3.
    What is Ant?“crawling insect living in colonies: an insect that lives in complex well-organized colonies and is noted for …” Encarta World English Dictionary
  • 4.
    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!”
  • 5.
    Make Limitations Shell-based:tied to a particular OS Makefile issues: tab vs. space
  • 6.
    Ant Advantages Platformindependent - thanks to Java! XML config files Tasks run by object implementing Task Interface
  • 7.
    How to useAnt Install Ant Get It from the Ant home page Install It (Optional) Build It Check Library Dependancies and Platform-dependant issues
  • 8.
    How to UseAnt Configured using an XML buildfile Buildfile contains one project and at least one target Targets contain Tasks
  • 9.
    Ant Buildfile Projects have three attributes Optional name - name of project Required default - task to perform Optional basedir - base directory used for path calculation <project name=”JavaSig&quot; default=&quot;deploy&quot; basedir=&quot;.&quot;>
  • 10.
    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
  • 11.
    Ant Buildfile -Target <target name=&quot;deploy&quot; depends=&quot;dist&quot;> <!-- Copy jars to the weblogic instance --> <copy preservelastmodified=&quot;yes&quot; todir=&quot;${deploy_dir}&quot;> <fileset dir=&quot;${dist}&quot;> <include name=&quot;*.jar&quot;/> <exclude name=”TestClients.jar&quot;/> </fileset> </copy> </target>
  • 12.
    Ant Buildfile -Targets Can depend on other targets Gets executed only once Can determine execution based on a property
  • 13.
    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 <javac srcdir=&quot;${src}&quot; destdir=&quot;${build}&quot;> <classpath refid=”compile.class.path&quot;/> </javac>
  • 14.
    Ant Buildfile -Properties Properties can be set for a project Setup using the <property> 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
  • 15.
    Ant Buildfile -Properties <!-- set global properties for this build --> <property name=&quot;src&quot; value=&quot;src&quot;/> <property name=&quot;build&quot; value=&quot;build&quot;/> <property name=&quot;dist&quot; value=&quot;dist&quot;/> <property name=&quot;lib&quot; value=&quot;lib&quot;/> <property name=&quot;archive&quot; value=&quot;archive&quot;/> <property name=&quot;weblogic.home&quot; value=&quot;c:\weblogic&quot;/> <property name=&quot;wl_lib&quot; value=&quot;${weblogic.home}/myserver/lib&quot;/>
  • 16.
    Ant Buildfile -PatternSets Patterns can be grouped in sets and referenced by id Defined by <patternset> element nested in a FileSet directory-based task stand alone element at target level
  • 17.
    Ant Buildfile -PatternSets <patternset> 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 <include> and <exclude> elements to specify patterns
  • 18.
    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 <patternset> elements Also holds an implicit PatternSet
  • 19.
    Ant Buildfile -FileSets <fileset dir=&quot;${build}&quot; includesfile=&quot;browseQueues.txt&quot;/> <fileset dir=&quot;${lib}/resources&quot; includes=&quot;**/BrowseQueues.properties&quot;/> <fileset dir=&quot;${dist}&quot;> <include name=&quot;*.jar&quot;/> <exclude name=&quot;GrinderTests.jar&quot;/> <exclude name=&quot;SystemTest.jar&quot;/> <exclude name=&quot;BrowseQueues.jar&quot;/> </fileset>
  • 20.
    Why Use Ant?Ease of Use/Configuration Extensibility Standardized Platform Independent It’s Java It’s Open Source
  • 21.
    Ant Resources Anthome page http://jakarta.apache.org/ant/index.html Ant User Manual http://jakarta.apache.org/ant/manual/index.html Ant Resources http://jakarta.apache.org/ant/resources.html “ Ant in Anger” http://jakarta.apache.org/ant/ant_in_anger.html