SlideShare a Scribd company logo
An Introduction to Ant
Overview
• What is Ant?
• Installing Ant
• Anatomy of a build file
– Projects
– Properties
– Targets
– Tasks
• Example build file
• Running a build file
What is Ant?
• Ant is a Java based tool for automating the build
process
• Similar to make but implemented using Java
– Platform independent commands (works on Windows,
Mac & Unix)
• XML based format
– Avoids the dreaded tab issue in make files
• Easily extendable using Java classes
• Ant is an open source (free) Apache project
Automating the Build (C & make)
• The goal is to automate the build process
a.out: driver.o foo.o bar.o
gcc driver.o foo.o bar.o
driver.o: driver.c foo.h bar.h
gcc -c driver.c
foo.o: foo.c foo.h
gcc -c foo.c
bar.o:
gcc -c bar.c
linux3[1]% make
gcc -c driver.c
gcc -c foo.c
gcc -c bar.c
gcc driver.o foo.o bar.o
linux3[2]%
foo.c foo.h bar.h bar.cdriver.c
foo.o bar.odriver.o
a.out
gcc -c foo.c gcc -c bar.cgcc -c driver.c
gcc driver.o foo.o bar.o
Installing Ant
• Ant can be downloaded from…
– http://ant.apache.org/
• Ant comes bundled as a zip file or a tarball
• Simply unwrap the file to some directory
where you want to store the executables
– I typically unwrap the zip file into C:Program
Files, and rename to C:Program Filesant
– This directory is known as ANT_HOME
Ant Setup
• Set the ANT_HOME environment variable to
where you installed Ant
• Add the ANT_HOME/bin directory to your path
• Set the JAVA_HOME environment variable to
the location where you installed Java
• Setting environment variables
– Windows: right click My Computer  Properties 
Advanced  Environment Variables
– UNIX: shell specific settings
Project Organization
• The following example assumes that your
workspace will be organized like so…
build.xml
Project Directory
src
*.java
bin
*.class
doc
*.html
Anatomy of a Build File
• Ant’s build files are written in XML
– Convention is to call file build.xml
• Each build file contains
– A project
– At least 1 target
• Targets are composed of some number of tasks
• Build files may also contain properties
– Like macros in a make file
• Comments are within <!-- --> blocks
Projects
• The project tag is used to define the
project you wish to work with
• Projects tags typically contain 3 attributes
– name – a logical name for the project
– default – the default target to execute
– basedir – the base directory for which all
operations are done relative to
• Additionally, a description for the project
can be specified from within the project
tag
Build File
<project name="Sample Project" default="compile" basedir=".">
<description>
A sample build file for this project
</description>
</project>
Properties
• Build files may contain constants (known
as properties) to assign a value to a
variable which can then be used
throughout the project
– Makes maintaining large build files more
manageable
• Projects can have a set of properties
• Property tags consist of a name/value pair
– Analogous to macros from make
Build File with Properties
<project name="Sample Project" default="compile" basedir=".">
<description>
A sample build file for this project
</description>
<!-- global properties for this build file -->
<property name="source.dir" location="src"/>
<property name="build.dir" location="bin"/>
<property name="doc.dir" location="doc"/>
</project>
Targets
• The target tag has the following required attribute
– name – the logical name for a target
• Targets may also have optional attributes such as
– depends – a list of other target names for which this task is
dependant upon, the specified task(s) get executed first
– description – a description of what a target does
• Like make files, targets in Ant can depend on some
number of other targets
– For example, we might have a target to create a jarfile, which
first depends upon another target to compile the code
• A build file may additionally specify a default target
Build File with Targets
<project name="Sample Project" default="compile" basedir=".">
...
<!-- set up some directories used by this project -->
<target name="init" description="setup project directories">
</target>
<!-- Compile the java code in src dir into build dir -->
<target name="compile" depends="init" description="compile java sources">
</target>
<!-- Generate javadocs for current project into docs dir -->
<target name="doc" depends="init" description="generate documentation">
</target>
<!-- Delete the build & doc directories and Emacs backup (*~) files -->
<target name="clean" description="tidy up the workspace">
</target>
</project>
Tasks
• A task represents an action that needs execution
• Tasks have a variable number of attributes which are
task dependant
• There are a number of build-in tasks, most of which are
things which you would typically do as part of a build
process
– Create a directory
– Compile java source code
– Run the javadoc tool over some files
– Create a jar file from a set of files
– Remove files/directories
– And many, many others…
• For a full list see: http://ant.apache.org/manual/coretasklist.html
Initialization Target & Tasks
• Our initialization target creates the build
and documentation directories
– The mkdir task creates a directory
<project name="Sample Project" default="compile" basedir=".">
...
<!-- set up some directories used by this project -->
<target name="init" description="setup project directories">
<mkdir dir="${build.dir}"/>
<mkdir dir="${doc.dir}"/>
</target>
...
</project>
Compilation Target & Tasks
• Our compilation target will compile all java
files in the source directory
– The javac task compiles sources into classes
– Note the dependence on the init task
<project name="Sample Project" default="compile" basedir=".">
...
<!-- Compile the java code in ${src.dir} into ${build.dir} -->
<target name="compile" depends="init" description="compile java sources">
<javac srcdir="${source.dir}" destdir="${build.dir}"/>
</target>
...
</project>
Javadoc Target & Tasks
• Our documentation target will create the
HTML documentation
– The javadoc task generates HTML
documentation for all sources
<project name="Sample Project" default="compile" basedir=".">
...
<!-- Generate javadocs for current project into ${doc.dir} -->
<target name="doc" depends="init" description="generate documentation">
<javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/>
</target>
...
</project>
Cleanup Target & Tasks
• We can also use ant to tidy up our
workspace
– The delete task removes files/directories from
the file system
<project name="Sample Project" default="compile" basedir=".">
...
<!-- Delete the build & doc directories and Emacs backup (*~) files -->
<target name="clean" description="tidy up the workspace">
<delete dir="${build.dir}"/>
<delete dir="${doc.dir}"/>
<delete>
<fileset defaultexcludes="no" dir="${source.dir}" includes="**/*~"/>
</delete>
</target>
...
</project>
Completed Build File (1 of 2)
<project name="Sample Project" default="compile" basedir=".">
<description>
A sample build file for this project
</description>
<!-- global properties for this build file -->
<property name="source.dir" location="src"/>
<property name="build.dir" location="bin"/>
<property name="doc.dir" location="doc"/>
<!-- set up some directories used by this project -->
<target name="init" description="setup project directories">
<mkdir dir="${build.dir}"/>
<mkdir dir="${doc.dir}"/>
</target>
<!-- Compile the java code in ${src.dir} into ${build.dir} -->
<target name="compile" depends="init" description="compile java sources">
<javac srcdir="${source.dir}" destdir="${build.dir}"/>
</target>
Completed Build File (2 of 2)
<!-- Generate javadocs for current project into ${doc.dir} -->
<target name="doc" depends="init" description="generate documentation">
<javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/>
</target>
<!-- Delete the build & doc directories and Emacs backup (*~) files -->
<target name="clean" description="tidy up the workspace">
<delete dir="${build.dir}"/>
<delete dir="${doc.dir}"/>
<delete>
<fileset defaultexcludes="no" dir="${source.dir}" includes="**/*~"/>
</delete>
</target>
</project>
Running Ant – Command Line
• Simply cd into the directory with the build.xml file
and type ant to run the project default target
• Or, type ant followed by the name of a target
Running Ant – Eclipse
• Eclipse comes with out of
the box support for Ant
– No need to separately
download and configure Ant
• Eclipse provides an Ant view
– Window  Show View  Ant
• Simply drag and drop a build
file into the Ant view, then
double click the target to run

More Related Content

What's hot

Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
Daniel Cukier
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)
Jacob Kaplan-Moss
 
Jsp
JspJsp
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packager
GaryCoady
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2
Graham Dumpleton
 
Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting for
Corneil du Plessis
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
fakedarren
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
Gordon Forsythe
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
Kris Wallsmith
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
Ben Scofield
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
Aaron Stannard
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Srijan Technologies
 
Powerful and flexible templates with Twig
Powerful and flexible templates with Twig Powerful and flexible templates with Twig
Powerful and flexible templates with Twig
Michael Peacock
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaImmutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS Lambda
AOE
 
Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)
Kris Wallsmith
 
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 MinutesDjangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Nina Zakharenko
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
Jace Ju
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework Scala
Kévin Margueritte
 

What's hot (20)

Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)
 
Jsp
JspJsp
Jsp
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packager
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2
 
Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting for
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
 
Powerful and flexible templates with Twig
Powerful and flexible templates with Twig Powerful and flexible templates with Twig
Powerful and flexible templates with Twig
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaImmutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS Lambda
 
Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)
 
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 MinutesDjangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework Scala
 

Viewers also liked

Kehebatan semut
Kehebatan semutKehebatan semut
Kehebatan semutNur Husna
 
Kroto semut presentation
Kroto semut presentationKroto semut presentation
Kroto semut presentation
dede nurcholis
 
ant colony algorithm
ant colony algorithmant colony algorithm
ant colony algorithm
bharatsharma88
 
The Ant Philosophy
The Ant PhilosophyThe Ant Philosophy
The Ant Philosophy
mehtprat
 
ANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTION
ANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTIONANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTION
ANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTION
Himanshu Srivastava
 
ANTS Presentation
ANTS PresentationANTS Presentation
ANTS Presentation
flutesusan
 
Ant colony Optimization
Ant colony OptimizationAnt colony Optimization
Ant colony Optimization
Swetanshmani Shrivastava
 
Ant - Management Lesson
Ant - Management LessonAnt - Management Lesson
Ant - Management Lesson
Rahul Tiwari
 
Ant Colony Optimization
Ant Colony OptimizationAnt Colony Optimization
Ant Colony Optimization
Pratik Poddar
 
Ant Colony Optimization: Routing
Ant Colony Optimization: RoutingAnt Colony Optimization: Routing
Ant Colony Optimization: Routing
Adrian Wilke
 
Ant colony optimization
Ant colony optimizationAnt colony optimization
Ant colony optimization
Meenakshi Devi
 
Ant colony optimization
Ant colony optimizationAnt colony optimization
Ant colony optimization
Joy Dutta
 

Viewers also liked (12)

Kehebatan semut
Kehebatan semutKehebatan semut
Kehebatan semut
 
Kroto semut presentation
Kroto semut presentationKroto semut presentation
Kroto semut presentation
 
ant colony algorithm
ant colony algorithmant colony algorithm
ant colony algorithm
 
The Ant Philosophy
The Ant PhilosophyThe Ant Philosophy
The Ant Philosophy
 
ANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTION
ANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTIONANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTION
ANT COLONY OPTIMIZATION FOR IMAGE EDGE DETECTION
 
ANTS Presentation
ANTS PresentationANTS Presentation
ANTS Presentation
 
Ant colony Optimization
Ant colony OptimizationAnt colony Optimization
Ant colony Optimization
 
Ant - Management Lesson
Ant - Management LessonAnt - Management Lesson
Ant - Management Lesson
 
Ant Colony Optimization
Ant Colony OptimizationAnt Colony Optimization
Ant Colony Optimization
 
Ant Colony Optimization: Routing
Ant Colony Optimization: RoutingAnt Colony Optimization: Routing
Ant Colony Optimization: Routing
 
Ant colony optimization
Ant colony optimizationAnt colony optimization
Ant colony optimization
 
Ant colony optimization
Ant colony optimizationAnt colony optimization
Ant colony optimization
 

Similar to Intro to-ant

Apache ant
Apache antApache ant
Apache ant
Yuriy Galavay
 
Apache Ant
Apache AntApache Ant
Apache Ant
Vinod Kumar V H
 
Apache ant
Apache antApache ant
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
Pavan Kumar N
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
Fabio Fumarola
 
Maven ii
Maven iiMaven ii
Maven ii
Sunil Komarapu
 
Building and Managing Projects with Maven
Building and Managing Projects with MavenBuilding and Managing Projects with Maven
Building and Managing Projects with Maven
Khan625
 
Maven ii
Maven iiMaven ii
Maven ii
Hasan Syed
 
Build Scripts
Build ScriptsBuild Scripts
Maven II
Maven IIMaven II
Maven part 2
Maven part 2Maven part 2
Maven part 2
Mohammed246
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
Arcadian Learning
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
Ryan Cuprak
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
Autoconf&Automake
Autoconf&AutomakeAutoconf&Automake
Autoconf&Automake
niurui
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To Ant
Rajesh Kumar
 
Host any project in che with stacks & chefiles
Host any project in che with stacks & chefilesHost any project in che with stacks & chefiles
Host any project in che with stacks & chefiles
Florent BENOIT
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
Sperasoft
 
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Codemotion
 
Gradle ex-machina
Gradle ex-machinaGradle ex-machina
Gradle ex-machina
Andres Almiray
 

Similar to Intro to-ant (20)

Apache ant
Apache antApache ant
Apache ant
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache ant
Apache antApache ant
Apache ant
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Maven ii
Maven iiMaven ii
Maven ii
 
Building and Managing Projects with Maven
Building and Managing Projects with MavenBuilding and Managing Projects with Maven
Building and Managing Projects with Maven
 
Maven ii
Maven iiMaven ii
Maven ii
 
Build Scripts
Build ScriptsBuild Scripts
Build Scripts
 
Maven II
Maven IIMaven II
Maven II
 
Maven part 2
Maven part 2Maven part 2
Maven part 2
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
Autoconf&Automake
Autoconf&AutomakeAutoconf&Automake
Autoconf&Automake
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To Ant
 
Host any project in che with stacks & chefiles
Host any project in che with stacks & chefilesHost any project in che with stacks & chefiles
Host any project in che with stacks & chefiles
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
 
Gradle ex-machina
Gradle ex-machinaGradle ex-machina
Gradle ex-machina
 

More from Manav Prasad

Experience with mulesoft
Experience with mulesoftExperience with mulesoft
Experience with mulesoft
Manav Prasad
 
Mulesoftconnectors
MulesoftconnectorsMulesoftconnectors
Mulesoftconnectors
Manav Prasad
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
Manav Prasad
 
Mulesoft cloudhub
Mulesoft cloudhubMulesoft cloudhub
Mulesoft cloudhub
Manav Prasad
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
Manav Prasad
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
Manav Prasad
 
Jpa
JpaJpa
Spring introduction
Spring introductionSpring introduction
Spring introduction
Manav Prasad
 
Json
Json Json
The spring framework
The spring frameworkThe spring framework
The spring framework
Manav Prasad
 
Rest introduction
Rest introductionRest introduction
Rest introduction
Manav Prasad
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
Manav Prasad
 
Junit
JunitJunit
Xml parsers
Xml parsersXml parsers
Xml parsers
Manav Prasad
 
Xpath
XpathXpath
Xslt
XsltXslt
Xhtml
XhtmlXhtml
Css
CssCss
Introduction to html5
Introduction to html5Introduction to html5
Introduction to html5
Manav Prasad
 
Ajax
AjaxAjax

More from Manav Prasad (20)

Experience with mulesoft
Experience with mulesoftExperience with mulesoft
Experience with mulesoft
 
Mulesoftconnectors
MulesoftconnectorsMulesoftconnectors
Mulesoftconnectors
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
 
Mulesoft cloudhub
Mulesoft cloudhubMulesoft cloudhub
Mulesoft cloudhub
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Jpa
JpaJpa
Jpa
 
Spring introduction
Spring introductionSpring introduction
Spring introduction
 
Json
Json Json
Json
 
The spring framework
The spring frameworkThe spring framework
The spring framework
 
Rest introduction
Rest introductionRest introduction
Rest introduction
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
 
Junit
JunitJunit
Junit
 
Xml parsers
Xml parsersXml parsers
Xml parsers
 
Xpath
XpathXpath
Xpath
 
Xslt
XsltXslt
Xslt
 
Xhtml
XhtmlXhtml
Xhtml
 
Css
CssCss
Css
 
Introduction to html5
Introduction to html5Introduction to html5
Introduction to html5
 
Ajax
AjaxAjax
Ajax
 

Recently uploaded

Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 

Recently uploaded (20)

Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 

Intro to-ant

  • 2. Overview • What is Ant? • Installing Ant • Anatomy of a build file – Projects – Properties – Targets – Tasks • Example build file • Running a build file
  • 3. What is Ant? • Ant is a Java based tool for automating the build process • Similar to make but implemented using Java – Platform independent commands (works on Windows, Mac & Unix) • XML based format – Avoids the dreaded tab issue in make files • Easily extendable using Java classes • Ant is an open source (free) Apache project
  • 4. Automating the Build (C & make) • The goal is to automate the build process a.out: driver.o foo.o bar.o gcc driver.o foo.o bar.o driver.o: driver.c foo.h bar.h gcc -c driver.c foo.o: foo.c foo.h gcc -c foo.c bar.o: gcc -c bar.c linux3[1]% make gcc -c driver.c gcc -c foo.c gcc -c bar.c gcc driver.o foo.o bar.o linux3[2]% foo.c foo.h bar.h bar.cdriver.c foo.o bar.odriver.o a.out gcc -c foo.c gcc -c bar.cgcc -c driver.c gcc driver.o foo.o bar.o
  • 5. Installing Ant • Ant can be downloaded from… – http://ant.apache.org/ • Ant comes bundled as a zip file or a tarball • Simply unwrap the file to some directory where you want to store the executables – I typically unwrap the zip file into C:Program Files, and rename to C:Program Filesant – This directory is known as ANT_HOME
  • 6. Ant Setup • Set the ANT_HOME environment variable to where you installed Ant • Add the ANT_HOME/bin directory to your path • Set the JAVA_HOME environment variable to the location where you installed Java • Setting environment variables – Windows: right click My Computer  Properties  Advanced  Environment Variables – UNIX: shell specific settings
  • 7. Project Organization • The following example assumes that your workspace will be organized like so… build.xml Project Directory src *.java bin *.class doc *.html
  • 8. Anatomy of a Build File • Ant’s build files are written in XML – Convention is to call file build.xml • Each build file contains – A project – At least 1 target • Targets are composed of some number of tasks • Build files may also contain properties – Like macros in a make file • Comments are within <!-- --> blocks
  • 9. Projects • The project tag is used to define the project you wish to work with • Projects tags typically contain 3 attributes – name – a logical name for the project – default – the default target to execute – basedir – the base directory for which all operations are done relative to • Additionally, a description for the project can be specified from within the project tag
  • 10. Build File <project name="Sample Project" default="compile" basedir="."> <description> A sample build file for this project </description> </project>
  • 11. Properties • Build files may contain constants (known as properties) to assign a value to a variable which can then be used throughout the project – Makes maintaining large build files more manageable • Projects can have a set of properties • Property tags consist of a name/value pair – Analogous to macros from make
  • 12. Build File with Properties <project name="Sample Project" default="compile" basedir="."> <description> A sample build file for this project </description> <!-- global properties for this build file --> <property name="source.dir" location="src"/> <property name="build.dir" location="bin"/> <property name="doc.dir" location="doc"/> </project>
  • 13. Targets • The target tag has the following required attribute – name – the logical name for a target • Targets may also have optional attributes such as – depends – a list of other target names for which this task is dependant upon, the specified task(s) get executed first – description – a description of what a target does • Like make files, targets in Ant can depend on some number of other targets – For example, we might have a target to create a jarfile, which first depends upon another target to compile the code • A build file may additionally specify a default target
  • 14. Build File with Targets <project name="Sample Project" default="compile" basedir="."> ... <!-- set up some directories used by this project --> <target name="init" description="setup project directories"> </target> <!-- Compile the java code in src dir into build dir --> <target name="compile" depends="init" description="compile java sources"> </target> <!-- Generate javadocs for current project into docs dir --> <target name="doc" depends="init" description="generate documentation"> </target> <!-- Delete the build & doc directories and Emacs backup (*~) files --> <target name="clean" description="tidy up the workspace"> </target> </project>
  • 15. Tasks • A task represents an action that needs execution • Tasks have a variable number of attributes which are task dependant • There are a number of build-in tasks, most of which are things which you would typically do as part of a build process – Create a directory – Compile java source code – Run the javadoc tool over some files – Create a jar file from a set of files – Remove files/directories – And many, many others… • For a full list see: http://ant.apache.org/manual/coretasklist.html
  • 16. Initialization Target & Tasks • Our initialization target creates the build and documentation directories – The mkdir task creates a directory <project name="Sample Project" default="compile" basedir="."> ... <!-- set up some directories used by this project --> <target name="init" description="setup project directories"> <mkdir dir="${build.dir}"/> <mkdir dir="${doc.dir}"/> </target> ... </project>
  • 17. Compilation Target & Tasks • Our compilation target will compile all java files in the source directory – The javac task compiles sources into classes – Note the dependence on the init task <project name="Sample Project" default="compile" basedir="."> ... <!-- Compile the java code in ${src.dir} into ${build.dir} --> <target name="compile" depends="init" description="compile java sources"> <javac srcdir="${source.dir}" destdir="${build.dir}"/> </target> ... </project>
  • 18. Javadoc Target & Tasks • Our documentation target will create the HTML documentation – The javadoc task generates HTML documentation for all sources <project name="Sample Project" default="compile" basedir="."> ... <!-- Generate javadocs for current project into ${doc.dir} --> <target name="doc" depends="init" description="generate documentation"> <javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/> </target> ... </project>
  • 19. Cleanup Target & Tasks • We can also use ant to tidy up our workspace – The delete task removes files/directories from the file system <project name="Sample Project" default="compile" basedir="."> ... <!-- Delete the build & doc directories and Emacs backup (*~) files --> <target name="clean" description="tidy up the workspace"> <delete dir="${build.dir}"/> <delete dir="${doc.dir}"/> <delete> <fileset defaultexcludes="no" dir="${source.dir}" includes="**/*~"/> </delete> </target> ... </project>
  • 20. Completed Build File (1 of 2) <project name="Sample Project" default="compile" basedir="."> <description> A sample build file for this project </description> <!-- global properties for this build file --> <property name="source.dir" location="src"/> <property name="build.dir" location="bin"/> <property name="doc.dir" location="doc"/> <!-- set up some directories used by this project --> <target name="init" description="setup project directories"> <mkdir dir="${build.dir}"/> <mkdir dir="${doc.dir}"/> </target> <!-- Compile the java code in ${src.dir} into ${build.dir} --> <target name="compile" depends="init" description="compile java sources"> <javac srcdir="${source.dir}" destdir="${build.dir}"/> </target>
  • 21. Completed Build File (2 of 2) <!-- Generate javadocs for current project into ${doc.dir} --> <target name="doc" depends="init" description="generate documentation"> <javadoc sourcepath="${source.dir}" destdir="${doc.dir}"/> </target> <!-- Delete the build & doc directories and Emacs backup (*~) files --> <target name="clean" description="tidy up the workspace"> <delete dir="${build.dir}"/> <delete dir="${doc.dir}"/> <delete> <fileset defaultexcludes="no" dir="${source.dir}" includes="**/*~"/> </delete> </target> </project>
  • 22. Running Ant – Command Line • Simply cd into the directory with the build.xml file and type ant to run the project default target • Or, type ant followed by the name of a target
  • 23. Running Ant – Eclipse • Eclipse comes with out of the box support for Ant – No need to separately download and configure Ant • Eclipse provides an Ant view – Window  Show View  Ant • Simply drag and drop a build file into the Ant view, then double click the target to run