Introduction To  Ant1
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Introduction To Ant1

on

  • 2,063 views

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.

Statistics

Views

Total Views
2,063
Views on SlideShare
1,609
Embed Views
454

Actions

Likes
0
Downloads
70
Comments
0

5 Embeds 454

http://www.scmgalaxy.com 445
http://scmgalaxy.com 4
https://www.linkedin.com 3
http://translate.googleusercontent.com 1
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction To Ant1 Presentation Transcript

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