SlideShare a Scribd company logo
1 of 31
Apache ANT
AGENDA
•   Introduction
•   Installing the ANT
•   A typical build file structure
•   Demos
Introduction
What is ANT
• Its not the insect that will bite you.
• Its not the wireless data transfer protocol like
  bluetooth.

• Then what is ANT?
  Answer:
  1. Ant is the acronym for Another Neat Tool.
  2. Its a Java-based build tool with the full portability of
  pure Java code.
• About the author: James Duncan Davidson.(Also the
  author of Apache Tomcat)
  http://en.wikipedia.org/wiki/James_Duncan_Davidson
Why ANT
• Its an open source project.
• OS independent: Builds run on both Windows
  and UNIX/Linux systems.
• You only need the JVM: It runs any where JVM is
  available.
• Works with anything that can be done from the
  command line
• Easy to extend (with Java)
• Moreover its not a programming language.
Similar Tools
• Make
• Maven
• NANT(For dot net)
• luntbuild
And Many more…..
Installation
Lets Get Started
1.   Download the binary.
2.   Install ANT.
3.   Write your build file.
4.   Run the build file.
Step 1: Download the Binary
• Download the binary:
  http://ant.apache.org/bindownload.cgi

Latest version is 1.8.2 released on Dec 27 2010.
Step 2:Install ANT
• Unzip downloaded file into a directory
• Setup Environment Variables
  – Define ANT_HOME to be the location where Ant
    was unzipped
  – Define JAVA_HOME to be the location where the
    JDK is installed
  – Add %ANT_HOME%bin to the PATH
Step 2: Install ANT
• Lets Test the installation:
    Open the CMD and write: ant
If it says:
Buildfile: build.xml does not exist! Build failed

       Hurray ANT is successfully installed!!!!!
                         
Step 3: A Simple build file
• <?xml version="1.0"?>
  <project>
      <target name="hello">
            <echo>Hello, World</echo>
      </target>
  </project>
Lets save this as “build1.xml”
Step 4: Lets Run This
• Goto CMD and move to the dir where you
  have put the simplebuild.xml
• Now write:
  ant –file build1.xml Hello_World_Target

This should show us Hello World.
A typical build file structure
The Structure
• Every build file will contain this three nodes:
  1. Project
  2. Target
  3. Task
         Project

                   Target(s)

                                     Tasj
                               Task(s)
The Project Tag
• Every thing inside the build file in ANT is under a
  project.
• Attributes: (None is mandatory)
  1. name > resembles the name of the project
  2. basedir > This is the directory from where all paths
  will be calculated. This can be overridden by using a
  “basedir” property. If both of these values are not set
  then “basedir“ value is the directory of the build file.
  3. default > Defines the default target for this project. If
  no target is provided then it will execute the “default”
  target
The Target tag
• Targets are containers of tasks that is defined to
  achieve certain states for build process.
• Attributes:
1. Name > name of the target (Required)
2. Description > Description for the target (NR)
3. Depends > Which target this current target depends
   upon. A comma separated list.
4. if > Execute target if value is set for a property
5. Unless > Execute the target if property value is not set
6. extensionOf > added from 1.8 (check next slide)
7. onMissingExtensionPoint > added from 1.8 (check
   next slide)
Extension-point
• Extension points are like targets except they
  only use the depends property.
   <target name=“target_1”>…….</target>
   <extension-point name=“extension_point_1" depends=“target_1"/>
   If we want to add a target to this depends list then we will
   define the “extensionOf “attribute for that target.
   <target name=“target_2” extensionOf=“extension_point_1”>…….</target>
Now if
   <target name=“target_3” depends=“extension_point_1”>…….</target>
Execution for target_3 : target_1->target_2->target_3

   If the extension_point_1 is missing and “onMissingExtensionPoint” is set
   then that target would be executed.
An example for targets
<target name=“target_1” description=“depends on none”>
<property name=“property_1”></property>
…….
</target>


<target name=“target_2” description=“gets executed if
   property_1 has a value” if=“property_1”>…..</target>


<target name=“target_3” description=“gets executed if
   property_1 has no value” unless=“property_1”>…..</target>
The ANT Tasks

• It’s the piece of code that can be executed.
• A task have multiple attributes or argument.
• The generic pattern for tasks:
  <name attribute1=“value1" attribute2="value2" ... />
• You can either use the build in tasks or you can build
  your own task(Not shown here).
Build in Tasks
• ANT Provides a lot of build in tasks. Here we
  will only look a few.
1. Archive Task: zip ,unzip
2. File Task: copy, delete
3. Execution Task: exec, antcall, sleep
4. Mail Task: mail
Zip and unzip a file with ANT
<?xml version="1.0" encoding="UTF-8"?>
<project name="zip-test" default="zip" basedir=".">
    <property name="project-name" value="${ant.project.name}" />
    <property name="folder-to-zip" value="zip-me" />
    <property name="unzip-destination" value="unzipped" />
    <target name="clean">
           <delete file="${project-name}.zip" />
           <delete dir="${unzip-destination}" />
    </target>
    <target name="zip">
           <zip destfile="${project-name}.zip" basedir="${folder-to-zip}" excludes="dont*.*" />
    </target>
    <target name="unzip">
           <unzip src="${project-name}.zip" dest="${unzip-destination}" />
    </target>
</project>
Exec Task
• Executes a system command.

<target name="target" description="Creating dump file from MSSQL ">
         <property name="dump.filepath" location="./dump.csv" />
         <property name="mssql.user" value=""/>
         <property name="mssql.password" value=""/>
         <property name="mssql.host" value=""/>
         <property name=“bcp" location="C:/Program Files/Microsoft SQL
   Server/90/Tools/Binn/bcp.EXE"/>
         <delete file="${dump.filepath}" />
         <exec executable="${bcp}" >
                  <arg line=' “put your query here"' />
                  <arg line=' queryout "${dump.filepath}" -c -t, -
   S${mssql.host} -U${mssql.user} -P${mssql.password}' />
         </exec>
</target>
Antcall Task
<?xml version="1.0" encoding="utf-8"?>
<project name="Test-antcall">
 <target name="root_target">
   <antcall target="target1"></antcall>
   <antcall target="target2"></antcall>
 </target>
 <target name="target1">
  <echo>I am target 1</echo>
  <sleep hours="1" minutes="-59" seconds="-55"/>
  <echo>Waked up from sleep of 5 seconds</echo>
 </target>
 <target name="target2">
  <echo>I am target 2</echo>
 </target>
</project>
Mail Task
<target name="sendmail">
   <mail tolist=“"
        from=“"
        subject="Email subject"
        mailhost=""
        mailport=""
        ssl=""
        user=““
        password=“">
        <message>Example email sent by Ant Mail
        task.</message>
   </mail>
</target>

    Please copy the mail.jar and activation.jar to the lib directory
File Task
<?xml version="1.0" encoding="utf-8"?>

<project name="deployclient" basedir=".">

 <target name="init">
  <property name="sourceDir" value="C:UsersNaseefDesktopMy Presentation On ANTtestDatabase" />
  <property name="outputDir" value="C:UsersNaseefDesktopMy Presentation On ANTtestdb" />
 </target>

 <target name="clean" depends="init">
  <delete dir="${outputDir}" />
 </target>

 <target name="prepare" depends="clean">
  <mkdir dir="${outputDir}" />
 </target>

 <target name="deploy" depends="prepare">
  <copy todir="${outputDir}">
   <dirset dir="${sourceDir}"
     excludes="a.svn">
   </dirset>
   <fileset dir="${sourceDir}"/>
  </copy>

  <delete>
   <fileset dir="." includes=".svn"/>
  </delete>
 </target>

</project>
Properties
• Properties are much like variables you declare.
• <property name=“property_name”
  location=“some_value”/>
• This property can be used as a argument value of
  a task. e.g
  <target name=“target1” description=“test target”>
        <property name=“property1” location=“place a value here”/>
        <mkdir dir=“${property1} “/>
  </target>
• The property name is case sensitive.
• Properties are immutable: whoever sets a
  property first freezes it for the rest of the build
Property Attributes
• Name: the name of the property to set.
• Value: the value of the property.
• Location: Sets the property to the absolute filename of
  the given file.
• File: the location of the properties file to load.
• Resource: the name of the classpath resource
  containing properties settings in properties file format.
• Classpath: the classpath to use when looking up a
  resource.
• Environment: environment the prefix to use when
  retrieving environment variables. An example is given
  in build2.xml
• There are many more….
Apache ANT command line options
• ant [options] [target [target2 [target3] ...]]
• Options:
      -help, -h
      -version print the version information and exit
       -diagnostics print information that might be
      helpful to diagnose or report problems.
      -verbose, -v be extra verbose
      - Quiet to be quite (donot show any thing)
      -debug, -d print debugging information
      -lib <path> specifies a path to search for jars and
      classes
      -logfile <file>, -l <file> use given file for log
Apache ANT command line options

• -buildfile <file>, -file <file>, -f <file> use given
  buildfile
• -D<property>=<value> use value for given
  property
• -propertyfile <name> load all properties from
  file with -D
Thank you very much
        Q/A

More Related Content

What's hot

Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Matthew McCullough
 
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
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra  SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra Sencha
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play FrameworkKnoldus Inc.
 
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
 
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011Alexander Klimetschek
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHPHari K T
 
Play Framework workshop: full stack java web app
Play Framework workshop: full stack java web appPlay Framework workshop: full stack java web app
Play Framework workshop: full stack java web appAndrew Skiba
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
 
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 MinutesNina Zakharenko
 
Tornado - different Web programming
Tornado - different Web programmingTornado - different Web programming
Tornado - different Web programmingDima Malenko
 

What's hot (20)

Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3
 
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!
 
Apache ant
Apache antApache ant
Apache ant
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra  SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
SenchaCon 2016: Learn the Top 10 Best ES2015 Features - Lee Boonstra
 
dJango
dJangodJango
dJango
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
 
Presentation
PresentationPresentation
Presentation
 
Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)
 
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
 
Play Framework workshop: full stack java web app
Play Framework workshop: full stack java web appPlay Framework workshop: full stack java web app
Play Framework workshop: full stack java web app
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
Tornadoweb
TornadowebTornadoweb
Tornadoweb
 
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
 
YouDrup_in_Drupal
YouDrup_in_DrupalYouDrup_in_Drupal
YouDrup_in_Drupal
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Tornado - different Web programming
Tornado - different Web programmingTornado - different Web programming
Tornado - different Web programming
 

Viewers also liked (9)

Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
ANT
ANTANT
ANT
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache ANT
Apache ANTApache ANT
Apache ANT
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 
Apache ant
Apache antApache ant
Apache ant
 

Similar to Apache ant

Similar to Apache ant (20)

Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guide
 
Phing
PhingPhing
Phing
 
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
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
CodeIgniter Ant Scripting
CodeIgniter Ant ScriptingCodeIgniter Ant Scripting
CodeIgniter Ant Scripting
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To Ant
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementPython and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
 
Build Scripts
Build ScriptsBuild Scripts
Build Scripts
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Write php deploy everywhere tek11
Write php deploy everywhere   tek11Write php deploy everywhere   tek11
Write php deploy everywhere tek11
 
GradleFX
GradleFXGradleFX
GradleFX
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013Puppet at Opera Sofware - PuppetCamp Oslo 2013
Puppet at Opera Sofware - PuppetCamp Oslo 2013
 
Any tutor
Any tutorAny tutor
Any tutor
 
Maven
MavenMaven
Maven
 
IzPack at LyonJUG'11
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 

Apache ant

  • 2. AGENDA • Introduction • Installing the ANT • A typical build file structure • Demos
  • 4. What is ANT • Its not the insect that will bite you. • Its not the wireless data transfer protocol like bluetooth. • Then what is ANT? Answer: 1. Ant is the acronym for Another Neat Tool. 2. Its a Java-based build tool with the full portability of pure Java code. • About the author: James Duncan Davidson.(Also the author of Apache Tomcat) http://en.wikipedia.org/wiki/James_Duncan_Davidson
  • 5. Why ANT • Its an open source project. • OS independent: Builds run on both Windows and UNIX/Linux systems. • You only need the JVM: It runs any where JVM is available. • Works with anything that can be done from the command line • Easy to extend (with Java) • Moreover its not a programming language.
  • 6. Similar Tools • Make • Maven • NANT(For dot net) • luntbuild And Many more…..
  • 8. Lets Get Started 1. Download the binary. 2. Install ANT. 3. Write your build file. 4. Run the build file.
  • 9. Step 1: Download the Binary • Download the binary: http://ant.apache.org/bindownload.cgi Latest version is 1.8.2 released on Dec 27 2010.
  • 10. Step 2:Install ANT • Unzip downloaded file into a directory • Setup Environment Variables – Define ANT_HOME to be the location where Ant was unzipped – Define JAVA_HOME to be the location where the JDK is installed – Add %ANT_HOME%bin to the PATH
  • 11. Step 2: Install ANT • Lets Test the installation: Open the CMD and write: ant If it says: Buildfile: build.xml does not exist! Build failed Hurray ANT is successfully installed!!!!! 
  • 12. Step 3: A Simple build file • <?xml version="1.0"?> <project> <target name="hello"> <echo>Hello, World</echo> </target> </project> Lets save this as “build1.xml”
  • 13. Step 4: Lets Run This • Goto CMD and move to the dir where you have put the simplebuild.xml • Now write: ant –file build1.xml Hello_World_Target This should show us Hello World.
  • 14. A typical build file structure
  • 15. The Structure • Every build file will contain this three nodes: 1. Project 2. Target 3. Task Project Target(s) Tasj Task(s)
  • 16. The Project Tag • Every thing inside the build file in ANT is under a project. • Attributes: (None is mandatory) 1. name > resembles the name of the project 2. basedir > This is the directory from where all paths will be calculated. This can be overridden by using a “basedir” property. If both of these values are not set then “basedir“ value is the directory of the build file. 3. default > Defines the default target for this project. If no target is provided then it will execute the “default” target
  • 17. The Target tag • Targets are containers of tasks that is defined to achieve certain states for build process. • Attributes: 1. Name > name of the target (Required) 2. Description > Description for the target (NR) 3. Depends > Which target this current target depends upon. A comma separated list. 4. if > Execute target if value is set for a property 5. Unless > Execute the target if property value is not set 6. extensionOf > added from 1.8 (check next slide) 7. onMissingExtensionPoint > added from 1.8 (check next slide)
  • 18. Extension-point • Extension points are like targets except they only use the depends property. <target name=“target_1”>…….</target> <extension-point name=“extension_point_1" depends=“target_1"/> If we want to add a target to this depends list then we will define the “extensionOf “attribute for that target. <target name=“target_2” extensionOf=“extension_point_1”>…….</target> Now if <target name=“target_3” depends=“extension_point_1”>…….</target> Execution for target_3 : target_1->target_2->target_3 If the extension_point_1 is missing and “onMissingExtensionPoint” is set then that target would be executed.
  • 19. An example for targets <target name=“target_1” description=“depends on none”> <property name=“property_1”></property> ……. </target> <target name=“target_2” description=“gets executed if property_1 has a value” if=“property_1”>…..</target> <target name=“target_3” description=“gets executed if property_1 has no value” unless=“property_1”>…..</target>
  • 20. The ANT Tasks • It’s the piece of code that can be executed. • A task have multiple attributes or argument. • The generic pattern for tasks: <name attribute1=“value1" attribute2="value2" ... /> • You can either use the build in tasks or you can build your own task(Not shown here).
  • 21. Build in Tasks • ANT Provides a lot of build in tasks. Here we will only look a few. 1. Archive Task: zip ,unzip 2. File Task: copy, delete 3. Execution Task: exec, antcall, sleep 4. Mail Task: mail
  • 22. Zip and unzip a file with ANT <?xml version="1.0" encoding="UTF-8"?> <project name="zip-test" default="zip" basedir="."> <property name="project-name" value="${ant.project.name}" /> <property name="folder-to-zip" value="zip-me" /> <property name="unzip-destination" value="unzipped" /> <target name="clean"> <delete file="${project-name}.zip" /> <delete dir="${unzip-destination}" /> </target> <target name="zip"> <zip destfile="${project-name}.zip" basedir="${folder-to-zip}" excludes="dont*.*" /> </target> <target name="unzip"> <unzip src="${project-name}.zip" dest="${unzip-destination}" /> </target> </project>
  • 23. Exec Task • Executes a system command. <target name="target" description="Creating dump file from MSSQL "> <property name="dump.filepath" location="./dump.csv" /> <property name="mssql.user" value=""/> <property name="mssql.password" value=""/> <property name="mssql.host" value=""/> <property name=“bcp" location="C:/Program Files/Microsoft SQL Server/90/Tools/Binn/bcp.EXE"/> <delete file="${dump.filepath}" /> <exec executable="${bcp}" > <arg line=' “put your query here"' /> <arg line=' queryout "${dump.filepath}" -c -t, - S${mssql.host} -U${mssql.user} -P${mssql.password}' /> </exec> </target>
  • 24. Antcall Task <?xml version="1.0" encoding="utf-8"?> <project name="Test-antcall"> <target name="root_target"> <antcall target="target1"></antcall> <antcall target="target2"></antcall> </target> <target name="target1"> <echo>I am target 1</echo> <sleep hours="1" minutes="-59" seconds="-55"/> <echo>Waked up from sleep of 5 seconds</echo> </target> <target name="target2"> <echo>I am target 2</echo> </target> </project>
  • 25. Mail Task <target name="sendmail"> <mail tolist=“" from=“" subject="Email subject" mailhost="" mailport="" ssl="" user=““ password=“"> <message>Example email sent by Ant Mail task.</message> </mail> </target> Please copy the mail.jar and activation.jar to the lib directory
  • 26. File Task <?xml version="1.0" encoding="utf-8"?> <project name="deployclient" basedir="."> <target name="init"> <property name="sourceDir" value="C:UsersNaseefDesktopMy Presentation On ANTtestDatabase" /> <property name="outputDir" value="C:UsersNaseefDesktopMy Presentation On ANTtestdb" /> </target> <target name="clean" depends="init"> <delete dir="${outputDir}" /> </target> <target name="prepare" depends="clean"> <mkdir dir="${outputDir}" /> </target> <target name="deploy" depends="prepare"> <copy todir="${outputDir}"> <dirset dir="${sourceDir}" excludes="a.svn"> </dirset> <fileset dir="${sourceDir}"/> </copy> <delete> <fileset dir="." includes=".svn"/> </delete> </target> </project>
  • 27. Properties • Properties are much like variables you declare. • <property name=“property_name” location=“some_value”/> • This property can be used as a argument value of a task. e.g <target name=“target1” description=“test target”> <property name=“property1” location=“place a value here”/> <mkdir dir=“${property1} “/> </target> • The property name is case sensitive. • Properties are immutable: whoever sets a property first freezes it for the rest of the build
  • 28. Property Attributes • Name: the name of the property to set. • Value: the value of the property. • Location: Sets the property to the absolute filename of the given file. • File: the location of the properties file to load. • Resource: the name of the classpath resource containing properties settings in properties file format. • Classpath: the classpath to use when looking up a resource. • Environment: environment the prefix to use when retrieving environment variables. An example is given in build2.xml • There are many more….
  • 29. Apache ANT command line options • ant [options] [target [target2 [target3] ...]] • Options: -help, -h -version print the version information and exit -diagnostics print information that might be helpful to diagnose or report problems. -verbose, -v be extra verbose - Quiet to be quite (donot show any thing) -debug, -d print debugging information -lib <path> specifies a path to search for jars and classes -logfile <file>, -l <file> use given file for log
  • 30. Apache ANT command line options • -buildfile <file>, -file <file>, -f <file> use given buildfile • -D<property>=<value> use value for given property • -propertyfile <name> load all properties from file with -D
  • 31. Thank you very much Q/A