An Introduction to Ant Bryan G. Hutchinson preEmptive Solutions, Inc.
An Introduction to Ant <ul><li>What is Ant? </li></ul><ul><li>How do you use it? </li></ul><ul><li>Why would you want to? ...
What is Ant? <ul><li>“crawling insect living in colonies: an insect that lives in complex well-organized colonies and is n...
What is Ant? <ul><li>According to Ant’s web site, ant is “ Apache Ant is a Java-based build tool. In theory, it is kind of...
Make Limitations <ul><li>Shell-based: tied to a particular OS </li></ul><ul><li>Makefile issues: tab vs. space </li></ul>
Ant Advantages <ul><li>Platform independent - thanks to Java! </li></ul><ul><li>XML config files </li></ul><ul><li>Tasks r...
How to use Ant <ul><li>Install Ant </li></ul><ul><ul><li>Get It from the Ant home page </li></ul></ul><ul><ul><li>Install ...
How to Use Ant <ul><li>Configured using an XML buildfile </li></ul><ul><li>Buildfile contains one  project  and at least o...
Ant Buildfile <ul><li>Projects  have three attributes </li></ul><ul><ul><li>Optional name - name of project </li></ul></ul...
Ant Buildfile <ul><li>A  project  defines one or more  targets </li></ul><ul><li>A  target  is a set of  tasks  to execute...
Ant Buildfile - Target <ul><li><target name=&quot;deploy&quot; depends=&quot;dist&quot;> </li></ul><ul><li><!-- Copy jars ...
Ant Buildfile - Targets <ul><li>Can depend on other targets </li></ul><ul><li>Gets executed only once </li></ul><ul><li>Ca...
Ant Buildfile - Tasks <ul><li>Code that can be executed </li></ul><ul><li>Can have multiple attributes </li></ul><ul><li>A...
Ant Buildfile - Properties <ul><li>Properties can be set for a project </li></ul><ul><li>Setup using the <property> task <...
Ant Buildfile - Properties <ul><li><!-- set global properties for this build --> </li></ul><ul><li><property name=&quot;sr...
Ant Buildfile - PatternSets <ul><li>Patterns can be grouped in sets and referenced by id </li></ul><ul><li>Defined by <pat...
Ant Buildfile - PatternSets <ul><li><patternset> has the following attributes: </li></ul><ul><ul><li>includes: list of pat...
Ant Buildfile - FileSets <ul><li>Groups of files </li></ul><ul><li>Used by many tasks </li></ul><ul><li>Files are found in...
Ant Buildfile - FileSets <ul><li><fileset dir=&quot;${build}&quot; includesfile=&quot;browseQueues.txt&quot;/> </li></ul><...
Why Use Ant? <ul><li>Ease of Use/Configuration </li></ul><ul><li>Extensibility </li></ul><ul><li>Standardized </li></ul><u...
Ant Resources <ul><li>Ant home page </li></ul><ul><li>http://jakarta.apache.org/ant/index.html </li></ul><ul><li>Ant User ...
Upcoming SlideShare
Loading in...5
×

Ant

2,644

Published on

Published in: Business, Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,644
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Ant

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

×