SlideShare une entreprise Scribd logo
1  sur  31
Apache Ant Hussain Fakhruddin [email_address]
Topics ,[object Object],[object Object],[object Object]
What is Ant “ Apache Ant is a Java-based build tool. In theory, it is kind of like Make, but without Make's wrinkles” -Apache Ant Website
Why Another such tool? ,[object Object],[object Object],[object Object],[object Object]
Why Ant then? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Where to get it ,[object Object],[object Object],[object Object]
Ant directory structure
Installing Ant ,[object Object]
Installing Ant ,[object Object]
Installing Ant ,[object Object]
build.xml ,[object Object],[object Object],[object Object]
build.xml ..Cont A build.xml file contains the following: Root Tag :  <project> Child Tag:  <target> (at least one) Sub Child Tag: <task>
Sample build.xml <project name=&quot;example&quot; default=&quot;hello&quot;> <target name=&quot;hello&quot;> <echo message=&quot;My First Ant&quot; /> </target> </project> Project tag(only one ) Task tag Target Tag (at least one)
Output
<project> ,[object Object],[object Object],[object Object],Three attributes of <project>
<target> ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<task> ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Properties ..Cont ,[object Object],[object Object],[object Object],[object Object],[object Object]
Sample build.xml with properties <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 structure used by compile --> <mkdir dir=&quot;${build}&quot;/> </target> <target name=&quot;compile&quot; depends=&quot;init&quot; description=&quot;compile the source &quot; > <!-- Compile the java 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> <target name=&quot;clean&quot; description=&quot;clean up&quot; > <!-- Delete the ${build} and ${dist} directory trees --> <delete dir=&quot;${build}&quot;/> <delete dir=&quot;${dist}&quot;/> </target> </project>
Hello World with Ant Lets compile , pack and run a simple Hello World program in Java. Step 1: Write your Java source code Step 2: Write a build.xml file Step 3: Run Ant with the build.xml
Step 1: Write a simple Hello World in Java public class HelloWorld{ public static void main(String []args) { System.out.println(“Hi, I am from Ant”); } }
Lets write the build.xml ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
build.xml  ..cont. Write a project with tasks to compile, package clean and run <project name=&quot;Hello World&quot; default=&quot;compile&quot;> <target name=&quot;compile&quot;> <mkdir dir=&quot;dist&quot; /> <javac srcdir=&quot;.&quot; destdir=&quot;dist&quot; /> </target> </project> Make a directory called “dist” Provide source and  destination directories
build.xml  ..cont <project name=&quot;Hello World&quot; default=&quot;compile&quot;> <target name=&quot;jar&quot;> <mkdir dir=&quot;dist/jar&quot;/>   <jar destfile=&quot;dist/jar/HelloWorld.jar&quot; basedir=&quot;dist&quot;>   <manifest>   <attribute name=&quot;Main-Class&quot; value=&quot;HelloWorld&quot;/>   </manifest> </jar> </target> <target name=&quot;compile&quot;> <mkdir dir=&quot;dist&quot; /> <javac srcdir=&quot;.&quot; destdir=&quot;dist&quot; /> </target> </project> Package Class Name
build.xml  ..cont <project name=&quot;Hello World&quot; default=&quot;compile&quot;> <target name=&quot;run&quot;> <java jar=&quot;dist/jar/HelloWorld.jar&quot; fork=&quot;true&quot;/> </target> <target name=&quot;clean&quot;> <delete dir=&quot;dist&quot;/> </target> <target name=&quot;jar&quot;> <mkdir dir=&quot;dist/jar&quot;/>   <jar destfile=&quot;dist/jar/HelloWorld.jar&quot; basedir=&quot;dist&quot;>   <manifest>   <attribute name=&quot;Main-Class&quot; value=&quot;HelloWorld&quot;/>   </manifest> </jar> </target> <target name=&quot;compile&quot;> <mkdir dir=&quot;dist&quot; /> <javac srcdir=&quot;.&quot; destdir=&quot;dist&quot; /> </target> </project> delete the directory created by <mkdir> in the beginning Execute this jar file
Run the Ant Place your files in the classpath and execute: ant compile ant jar ant run or simply, ant compile jar run
Output
Ant Resources Homepage:  http://ant.apache.org User Manual:  http://jakarta.apache.org/ant/manual/index.html Wiki:  http://wiki.apache.org/ant/FrontPage FAQ:  http://ant.apache.org/faq.html Books:  http://sourceforge.net/projects/antbook Contribution: http://www.apache.org/foundation/contributing.html
Queries?
Thanks for your time About the Author: Hussain Fakhruddin [email_address]

Contenu connexe

Tendances

Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
Kanika2885
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
Dmitry Buzdin
 

Tendances (18)

Apache ant
Apache antApache ant
Apache ant
 
Ant tutorial
Ant tutorialAnt tutorial
Ant tutorial
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 
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
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To Ant
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
 
dJango
dJangodJango
dJango
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Django
DjangoDjango
Django
 
Deploy Flex with Apache Ant
Deploy Flex with Apache AntDeploy Flex with Apache Ant
Deploy Flex with Apache Ant
 
Learning Puppet Chapter 1
Learning Puppet Chapter 1Learning Puppet Chapter 1
Learning Puppet Chapter 1
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwal
 

En vedette

Apache Ant
Apache AntApache Ant
Apache Ant
Ali Bahu
 
Apache Ant
Apache AntApache Ant
Apache Ant
teejug
 
Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase
Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase
Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase
Kai Wähner
 
Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)
Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)
Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)
Kai Wähner
 

En vedette (15)

ANT
ANTANT
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
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Apache ANT
Apache ANTApache ANT
Apache ANT
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Trends at JavaOne 2016: Microservices, Docker and Cloud-Native Middleware
Trends at JavaOne 2016: Microservices, Docker and Cloud-Native MiddlewareTrends at JavaOne 2016: Microservices, Docker and Cloud-Native Middleware
Trends at JavaOne 2016: Microservices, Docker and Cloud-Native Middleware
 
Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase
Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase
Blockchain + Streaming Analytics with Ethereum and TIBCO StreamBase
 
Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)
Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)
Flogo - A Golang-powered Open Source IoT Integration Framework (Gophercon)
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with docker
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
 

Similaire à Apache Ant

Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
Kanika2885
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
Magecom Ukraine
 
PHP North East Registry Pattern
PHP North East Registry PatternPHP North East Registry Pattern
PHP North East Registry Pattern
Michael Peacock
 
PHP North East - Registry Design Pattern
PHP North East - Registry Design PatternPHP North East - Registry Design Pattern
PHP North East - Registry Design Pattern
Michael Peacock
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
Suite Solutions
 

Similaire à Apache Ant (20)

Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 
Ant
Ant Ant
Ant
 
Using Ant To Build J2 Ee Applications
Using Ant To Build J2 Ee ApplicationsUsing Ant To Build J2 Ee Applications
Using Ant To Build J2 Ee Applications
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
 
Introduction To Ant1
Introduction To  Ant1Introduction To  Ant1
Introduction To Ant1
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
Java ant tutorial
Java ant tutorialJava ant tutorial
Java ant tutorial
 
Migration testing framework
Migration testing frameworkMigration testing framework
Migration testing framework
 
Ant Build Tool
Ant Build ToolAnt Build Tool
Ant Build Tool
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
PHP North East Registry Pattern
PHP North East Registry PatternPHP North East Registry Pattern
PHP North East Registry Pattern
 
PHP North East - Registry Design Pattern
PHP North East - Registry Design PatternPHP North East - Registry Design Pattern
PHP North East - Registry Design Pattern
 
Selenium RC Automation testing
Selenium RC Automation testingSelenium RC Automation testing
Selenium RC Automation testing
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guide
 
Creating Yahoo Mobile Widgets
Creating Yahoo Mobile WidgetsCreating Yahoo Mobile Widgets
Creating Yahoo Mobile Widgets
 
Xml Zoe
Xml ZoeXml Zoe
Xml Zoe
 
Xml Zoe
Xml ZoeXml Zoe
Xml Zoe
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 

Plus de hussulinux

Effective communication
Effective communicationEffective communication
Effective communication
hussulinux
 
Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273
hussulinux
 

Plus de hussulinux (10)

Effective communication
Effective communicationEffective communication
Effective communication
 
Enterprise Application Framework
Enterprise Application FrameworkEnterprise Application Framework
Enterprise Application Framework
 
Direct Web Remoting : DWR
Direct Web Remoting : DWRDirect Web Remoting : DWR
Direct Web Remoting : DWR
 
PHP MySQL Training : Module 3
PHP MySQL Training : Module 3PHP MySQL Training : Module 3
PHP MySQL Training : Module 3
 
PHP MySQL Training : Module 2
PHP MySQL Training : Module 2PHP MySQL Training : Module 2
PHP MySQL Training : Module 2
 
PHP Training: Module 1
PHP Training: Module 1PHP Training: Module 1
PHP Training: Module 1
 
Auto Forex Trade with Meta Trader 4
Auto Forex Trade with Meta Trader 4Auto Forex Trade with Meta Trader 4
Auto Forex Trade with Meta Trader 4
 
Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273Linux Apache Php Mysql Lamp1273
Linux Apache Php Mysql Lamp1273
 
Mobile Navigation
Mobile NavigationMobile Navigation
Mobile Navigation
 
Flash Widget Tutorial
Flash Widget TutorialFlash Widget Tutorial
Flash Widget Tutorial
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Apache Ant

  • 1. Apache Ant Hussain Fakhruddin [email_address]
  • 2.
  • 3. What is Ant “ Apache Ant is a Java-based build tool. In theory, it is kind of like Make, but without Make's wrinkles” -Apache Ant Website
  • 4.
  • 5.
  • 6.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. build.xml ..Cont A build.xml file contains the following: Root Tag : <project> Child Tag: <target> (at least one) Sub Child Tag: <task>
  • 13. Sample build.xml <project name=&quot;example&quot; default=&quot;hello&quot;> <target name=&quot;hello&quot;> <echo message=&quot;My First Ant&quot; /> </target> </project> Project tag(only one ) Task tag Target Tag (at least one)
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20. Sample build.xml with properties <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 structure used by compile --> <mkdir dir=&quot;${build}&quot;/> </target> <target name=&quot;compile&quot; depends=&quot;init&quot; description=&quot;compile the source &quot; > <!-- Compile the java 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> <target name=&quot;clean&quot; description=&quot;clean up&quot; > <!-- Delete the ${build} and ${dist} directory trees --> <delete dir=&quot;${build}&quot;/> <delete dir=&quot;${dist}&quot;/> </target> </project>
  • 21. Hello World with Ant Lets compile , pack and run a simple Hello World program in Java. Step 1: Write your Java source code Step 2: Write a build.xml file Step 3: Run Ant with the build.xml
  • 22. Step 1: Write a simple Hello World in Java public class HelloWorld{ public static void main(String []args) { System.out.println(“Hi, I am from Ant”); } }
  • 23.
  • 24. build.xml ..cont. Write a project with tasks to compile, package clean and run <project name=&quot;Hello World&quot; default=&quot;compile&quot;> <target name=&quot;compile&quot;> <mkdir dir=&quot;dist&quot; /> <javac srcdir=&quot;.&quot; destdir=&quot;dist&quot; /> </target> </project> Make a directory called “dist” Provide source and destination directories
  • 25. build.xml ..cont <project name=&quot;Hello World&quot; default=&quot;compile&quot;> <target name=&quot;jar&quot;> <mkdir dir=&quot;dist/jar&quot;/> <jar destfile=&quot;dist/jar/HelloWorld.jar&quot; basedir=&quot;dist&quot;> <manifest> <attribute name=&quot;Main-Class&quot; value=&quot;HelloWorld&quot;/> </manifest> </jar> </target> <target name=&quot;compile&quot;> <mkdir dir=&quot;dist&quot; /> <javac srcdir=&quot;.&quot; destdir=&quot;dist&quot; /> </target> </project> Package Class Name
  • 26. build.xml ..cont <project name=&quot;Hello World&quot; default=&quot;compile&quot;> <target name=&quot;run&quot;> <java jar=&quot;dist/jar/HelloWorld.jar&quot; fork=&quot;true&quot;/> </target> <target name=&quot;clean&quot;> <delete dir=&quot;dist&quot;/> </target> <target name=&quot;jar&quot;> <mkdir dir=&quot;dist/jar&quot;/> <jar destfile=&quot;dist/jar/HelloWorld.jar&quot; basedir=&quot;dist&quot;> <manifest> <attribute name=&quot;Main-Class&quot; value=&quot;HelloWorld&quot;/> </manifest> </jar> </target> <target name=&quot;compile&quot;> <mkdir dir=&quot;dist&quot; /> <javac srcdir=&quot;.&quot; destdir=&quot;dist&quot; /> </target> </project> delete the directory created by <mkdir> in the beginning Execute this jar file
  • 27. Run the Ant Place your files in the classpath and execute: ant compile ant jar ant run or simply, ant compile jar run
  • 29. Ant Resources Homepage: http://ant.apache.org User Manual: http://jakarta.apache.org/ant/manual/index.html Wiki: http://wiki.apache.org/ant/FrontPage FAQ: http://ant.apache.org/faq.html Books: http://sourceforge.net/projects/antbook Contribution: http://www.apache.org/foundation/contributing.html
  • 31. Thanks for your time About the Author: Hussain Fakhruddin [email_address]