Your SlideShare is downloading. ×
0
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Introduction To  Ant1
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction To Ant1

1,555

Published on

Ant is a Java library and command-line tool. Ant's mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the …

Ant is a Java library and command-line tool. Ant's mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks.

Ant is written in Java. Users of Ant can develop their own "antlibs" containing Ant tasks and types, and are offered a large number of ready-made commercial or open-source "antlibs".

Ant is extremely flexible and does not impose coding conventions or directory layouts to the Java projects which adopt it as a build tool.

Software development projects looking for a solution combining build tool and dependency management can use Ant in combination with Ivy.

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

  • Be the first to like this

No Downloads
Views
Total Views
1,555
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
75
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to ANT www.scmGalaxy.com scmGalaxy Author: Rajesh Kumar [email_address]
  • 2. Agenda <ul><li>What is Ant? </li></ul><ul><li>Why is it called ANT? </li></ul><ul><li>Advantages of ANT </li></ul><ul><li>How does ANT work? </li></ul><ul><li>Sample Build file </li></ul><ul><li>Executing An Ant Script </li></ul><ul><li>Some Simple Ant Commands </li></ul><ul><li>References </li></ul>
  • 3. What is Ant? <ul><li>A build tool </li></ul><ul><li>Open Source </li></ul><ul><li>Part of Apache’s Jakarta project. </li></ul><ul><li>Implemented in Java </li></ul><ul><li>Written for Java </li></ul><ul><li>Used to build many open-source Java projects </li></ul>
  • 4. Why is it called ANT? <ul><li>According to the author (James Duncan Davidson)… </li></ul><ul><li>Because ants do an extremely good job of building things. </li></ul><ul><li>Stands for “Another Neat Tool” </li></ul>
  • 5. Advantages of ANT <ul><li>Only requires a Java VM to use. </li></ul><ul><li>It is extended using Java classes, which makes it almost like fun for Java developers. </li></ul><ul><li>Easier to do Java-specific tasks, such as JavaDocs, WAR and JAR files, and Enterprise JavaBeans. </li></ul><ul><li>Instead of writing cryptic shell commands, the configuration files are easy to read XML. </li></ul><ul><li>Each “task” is defined in a separate XML block, making adding or removing additional tasks easier. </li></ul>
  • 6. Advantages Continued <ul><li>It’s FAST! (Uses the same VM for entire process) </li></ul><ul><li>Because it is Java based, it is easily expandable, and inherently cross-platform. </li></ul><ul><li>All of the cool Java IDEs have built-in support for Ant. </li></ul><ul><li>It can easily operate recursively, so only one Ant build script is required for most projects. </li></ul><ul><li>Ant has built-in CVS support. </li></ul><ul><li>Ant has built-in FTP support. </li></ul><ul><li>Ant has built-in JUnit support. </li></ul>
  • 7. How does ANT work? <ul><li>Ant commands (or tasks) are implemented by Java classes </li></ul><ul><ul><li>many tasks are in-built or come in JAR files </li></ul></ul><ul><ul><li>custom commands can be easily created </li></ul></ul><ul><li>Each project using Ant will have a build file </li></ul><ul><ul><li>called build.xml – Ant’s default </li></ul></ul><ul><li>Each build file is composed of any number of targets </li></ul><ul><ul><li>corresponding to common activities like compiling and running code </li></ul></ul>
  • 8. How does ANT work? (contd) <ul><li>Each target is composed of tasks </li></ul><ul><ul><li>executed in sequence when the target is executed </li></ul></ul><ul><ul><li>Ant targets can have dependencies </li></ul></ul><ul><ul><ul><li>for example, the build file may have a task to run file C, and can specify that before the file C can be run, package B needs to be compiled, and before package B is compiled, package A must be compiled. </li></ul></ul></ul>
  • 9. Build file: example <ul><li><project name=&quot;MyProject&quot; default=&quot;dist&quot; basedir=&quot;.&quot;> </li></ul><ul><li><description> </li></ul><ul><li>simple example build file </li></ul><ul><li></description> </li></ul><ul><li><!-- set global properties for this build --> </li></ul><ul><li><property name=&quot;src&quot; location=&quot;src&quot;/> </li></ul><ul><li><property name=&quot;build&quot; location=&quot;build&quot;/> </li></ul><ul><li><property name=&quot;dist&quot; location=&quot;dist&quot;/> </li></ul><ul><li><target name=&quot;init&quot;> </li></ul><ul><li><!-- Create the time stamp --> </li></ul><ul><li><tstamp/> </li></ul><ul><li><!-- Create the build directory used by compile --> </li></ul><ul><li><mkdir dir=&quot;${build}&quot;/> </li></ul><ul><li></target> </li></ul>
  • 10. Build file: example <ul><li><target name=&quot;compile&quot; depends=&quot;init&quot; </li></ul><ul><li>description=&quot;compile the source &quot; > </li></ul><ul><li><!-- Compile code from ${src} into ${build} --> </li></ul><ul><li><javac srcdir=&quot;${src}&quot; destdir=&quot;${build}&quot;/> </li></ul><ul><li></target> </li></ul><ul><li><target name=&quot;dist&quot; depends=&quot;compile&quot; </li></ul><ul><li>description=&quot;generate the distribution&quot; > </li></ul><ul><li><!-- Create the distribution directory --> </li></ul><ul><li><mkdir dir=&quot;${dist}/lib&quot;/> </li></ul><ul><li><!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> </li></ul><ul><li><jar jarfile=&quot;${dist}/lib/MyProject-${DSTAMP}.jar&quot; basedir=&quot;${build}&quot;/> </li></ul><ul><li></target> </li></ul>
  • 11. Build file: example <ul><li><target name=&quot;clean&quot; </li></ul><ul><li>description=&quot;clean up&quot; > </li></ul><ul><li><!-- Delete ${build} and ${dist} dirs --> </li></ul><ul><li><delete dir=&quot;${build}&quot;/> </li></ul><ul><li><delete dir=&quot;${dist}&quot;/> </li></ul><ul><li></target> </li></ul><ul><li></project> </li></ul>
  • 12. Executing An Ant Script <ul><li>In its basic form, an Ant script can be run by simply typing “Ant” </li></ul><ul><li>Command-line option summary: ant [options] [target [target2 [target3] ...]] </li></ul><ul><li>Options (trimmed to fit page): -help print this message -version print the version information and </li></ul><ul><li>exit -logfile file use given file for log output -logger classname the class that performs logging -buildfile file use specified buildfile </li></ul>
  • 13. Some Ant Commands <ul><li><ant/> </li></ul><ul><li>calls a target in another build file </li></ul><ul><li>useful to build subprojects </li></ul><ul><li><ant antfile=&quot;subproject/subbuild.xml&quot; dir=&quot;subproject&quot; target=&quot;compile&quot;/> </li></ul><ul><li><cvs/> executes any CVS command </li></ul><ul><li><cvs cvsRoot=&quot;:pserver:anoncvs@cvs.apache.org:/home/cvspublic&quot; package=&quot;ant&quot; dest=&quot;${ws.dir}&quot; /> </li></ul><ul><li><exec/> executes a system command </li></ul><ul><li><exec dir=&quot;${src}&quot; executable=&quot;cmd.exe&quot; os=&quot;Windows 2000&quot; output=&quot;dir.txt&quot;> <arg line=&quot;/c dir&quot;/> </exec> </li></ul>
  • 14. Some Ant Commands <ul><li><javadoc/> </li></ul><ul><li>generates javadoc HTML files from Java source files </li></ul><ul><li><javadoc packagenames=&quot;com.dummy.test.*&quot; </li></ul><ul><li>sourcepath=&quot;src&quot; </li></ul><ul><li>excludepackagenames=&quot;com.dummy.test.doc-files.*&quot; </li></ul><ul><li>destdir=&quot;docs/api&quot; author=&quot;true&quot; version=&quot;true&quot; /> </li></ul><ul><li><mail/> sends email using SMTP </li></ul><ul><li><mail from=&quot;me&quot; tolist=&quot;you&quot; subject=&quot;Results of nightly build&quot; files=&quot;build.log&quot;/> </li></ul><ul><li><mkdir/> </li></ul><ul><li>creates a directory and any missing parent directories </li></ul><ul><li><mkdir dir=&quot;${dist}&quot;/> </li></ul>
  • 15. Some Ant Commands <ul><li><sql/> </li></ul><ul><li>executes a sequence of SQL statements specified in the build file or an external text file, output can be written to a file </li></ul><ul><li><sql driver=&quot;org.database.jdbcDriver&quot; url=&quot;jdbc:database-url&quot; userid=&quot;sa&quot; password=&quot;pass&quot; src=&quot;data.sql&quot; > </li></ul><ul><li>insert into table some_table values(1,2,3,4); </li></ul><ul><li></sql> </li></ul><ul><li><unjar/> expands a JAR file </li></ul><ul><li><untar/> expands a TAR file </li></ul>
  • 16. References The ANT manual at ant.apache.org http://ant.apache.org/manual/
  • 17. www.scmGalaxy.com Thank You ! Author: Rajesh Kumar [email_address]

×