SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Apache Ant
Presented By,
Vinod Kumar V H
Build Tools
• Dependency Management
• Version
• Compile java code, build jars
• Custom Control
Why do we need build tools
• Creating a product from source may take
several steps: compile, link, copy files to
various directories, remove intermediate files,
generate documentation.
• The objective should be an automated tool that
does all the work for you. Type or click one
command and create a final product.
• There are a couple of ways this can be done:
– Write a batch file or script
• The scripts tend to be hard to maintain
– Use a tool designed for the task
• Ant
What is ANT
• Java based free build tool from
Apache - Build IN Java, USING
Java, and FOR Java
• ANT uses XML based configuration
“Build” file to drive its actions.
• To create powerful Ant build files to
compile and bundle applications in
.jar, .ear, or .war files, and to deploy
J2EE software applications
Ant
Compiler
JUnit
Source Control
Why ANT
• Written in Java so it’s a Cross-Platform build tool
– Cross platform build files support developers working
on different operating systems
• Instead of writing shell commands, the
configuration files are XML based which are
easy to read and modify.
• Faster since each command is executed from
within JVM.
• One-time setup hassle provides easy building of
a project
• Ant's Debug Options are very helpful
Installing Ant
• Download Ant binary distribution from:
http://ant.apache.org/bindownload.cgi
• Set ANT_HOME to where you installed Ant
• Include $ANT_HOME/bin in PATH
• Make sure JAVA_HOME is set to point to JDK
• Assume Ant is installed in c:ant. The
following sets up the environment:
set ANT_HOME=c:ant
set JAVA_HOME=c:j2sdk1.6.0_24
set PATH=%PATH%;%ANT_HOME%bin
ANT Directory Structure
How ANT works
• Each build file has exactly one project.
• Each Build File is made up of at least
one target.
– Examples are: 'compile', ‘build', 'clean', etc.
• Each Target is made up of Tasks
– which are executed in a sequence
• Targets can have Dependencies
– Examples: 'install' depends on 'compile'
– Can handle cascading dependencies
– Each Dependency is handled only once
Structure of BUILD File
<?xml version="1.0"?>
<project name="Ant-Test" default="main" basedir=".">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="src.dir" location="src" />
<property name="build.dir" location="bin" />
<property name="dist.dir" location="dist" />
<property name="docs.dir" location="docs" />
<!-- Deletes the existing build, docs and dist directory-->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${docs.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Creates the build, docs and dist directory-->
<target name="makedir">
<mkdir dir="${build.dir}" />
<mkdir dir="${docs.dir}" />
<mkdir dir="${dist.dir}" />
</target>
Structure of BUILD File Contd…
<!-- Compiles the java code (including the usage of library for JUnit -->
<target name="compile" depends="clean, makedir">
<javac srcdir="${src.dir}" destdir="${build.dir}">
</javac>
</target>
<!-- Creates Javadoc -->
<target name="docs" depends="compile">
<javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
<!-- Define which files / directory should get included, we include all -->
<fileset dir="${src.dir}">
<include name="**" />
</fileset>
</javadoc>
</target>
<!--Creates the deployable jar file -->
<target name="jar" depends="compile">
<jar destfile="${dist.dir}de.vogella.build.test.ant.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="test.Main" />
</manifest>
</jar>
</target>
<target name="main" depends="compile, jar, docs">
<description>Main target</description>
</target> </project>
Useful Target Definitions
 Init : Sets up properties that will be used
throughout the build file. Properties can be
set directly or by specifying a properties
file.
 Prepare : Create any directory structure
which is needed.
 Clean : clean is useful for enabling clean
builds. Generally just deletes stuff from
previous runs. (ant clean build)
 Compile : Compile some/all of your source
files in this target
 Jar : Creates a jar file from the stuff you’ve
built
Tasks Contd…
• javac - The javac task compiles Java
source into class files,just as the javac
command-line tool does. Ant will recompile
only those files that have changed.
• java - Execute a Java class
• javadoc - Generates JavaDoc from your
source files
• jar (and war) - Create JAR files
• mkdir - Makes a directory
• copy - Copies files to specified location
• exec - allows different commands to be
executed based on the OS it is executing
on.
Tasks Contd…
• delete - Deletes specified files
• parallel - Runs two or more Ant tasks (not
targets) simultaneously in separate threads
• Import - Includes another build file into the
current file
• echo - Prints a message to the console
(default) or a file
• antcall - Calls another target within the same
build file
• ant - Calls another target on a different build
file
• FTP - lists, gets, puts and deletes files on an
FTP server
Note : You can also write your own tasks.
Summary
• Ant is a cross-platform build tool for
Java.
• Ant uses XML based configuration
file typically named 'build.xml'.
• Project, Targets and Tasks
- A build.xml would contain 1 project
with one or more targets and each of
the target containing one or more
tasks.
Thank ‘U’

Weitere ähnliche Inhalte

Was ist angesagt?

HTML 5 Tables and Forms
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and Forms
Doncho Minkov
 
Java servlets
Java servletsJava servlets
Java servlets
lopjuan
 

Was ist angesagt? (20)

Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
HTML 5 Tables and Forms
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and Forms
 
React native
React nativeReact native
React native
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrap
 
Spring boot
Spring bootSpring boot
Spring boot
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 
Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Javascript by geetanjali
Javascript by geetanjaliJavascript by geetanjali
Javascript by geetanjali
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Spring & hibernate
Spring & hibernateSpring & hibernate
Spring & hibernate
 
Le Wagon - UI components design
Le Wagon - UI components designLe Wagon - UI components design
Le Wagon - UI components design
 
Techical Workflow for a Startup
Techical Workflow for a StartupTechical Workflow for a Startup
Techical Workflow for a Startup
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Sql injection attack
Sql injection attackSql injection attack
Sql injection attack
 
Java servlets
Java servletsJava servlets
Java servlets
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 

Andere mochten auch

Apache ant
Apache antApache ant
Apache ant
koniik
 
Apache Ant
Apache AntApache Ant
Apache Ant
teejug
 
Apache Ant
Apache AntApache Ant
Apache Ant
Ali Bahu
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
Kanika2885
 
Apache Ant
Apache AntApache Ant
Apache Ant
Ali Bahu
 

Andere mochten auch (14)

Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Apache ant
Apache antApache ant
Apache ant
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache ANT
Apache ANTApache ANT
Apache ANT
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
ANT
ANTANT
ANT
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 
Apache ant
Apache antApache ant
Apache ant
 

Ähnlich wie Apache Ant

Gnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-semGnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-sem
Sagun Baijal
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
Hannes Hapke
 
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
 
Java build tools
Java build toolsJava build tools
Java build tools
Sujit Kumar
 

Ähnlich wie Apache Ant (20)

Intro to-ant
Intro to-antIntro to-ant
Intro to-ant
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
 
Gnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-semGnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-sem
 
Autoconf&Automake
Autoconf&AutomakeAutoconf&Automake
Autoconf&Automake
 
How to run appache spark on windows(in sbt console)
How to run appache spark on windows(in sbt console)How to run appache spark on windows(in sbt console)
How to run appache spark on windows(in sbt console)
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guide
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2
 
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
 
Java Build Tools
Java Build ToolsJava Build Tools
Java Build Tools
 
Java build tools
Java build toolsJava build tools
Java build tools
 
DevOpsDays InSpec Workshop
DevOpsDays InSpec WorkshopDevOpsDays InSpec Workshop
DevOpsDays InSpec Workshop
 
Java ant tutorial
Java ant tutorialJava ant tutorial
Java ant tutorial
 
Ant tutorial
Ant tutorialAnt tutorial
Ant tutorial
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 

Mehr von Vinod Kumar V H (6)

Captcha
CaptchaCaptcha
Captcha
 
Team work & Interpersonal skills
Team work & Interpersonal skillsTeam work & Interpersonal skills
Team work & Interpersonal skills
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Augmented Reality
Augmented RealityAugmented Reality
Augmented Reality
 
Thin Client
Thin ClientThin Client
Thin Client
 
Thin client
Thin clientThin client
Thin client
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 

Apache Ant

  • 2. Build Tools • Dependency Management • Version • Compile java code, build jars • Custom Control
  • 3. Why do we need build tools • Creating a product from source may take several steps: compile, link, copy files to various directories, remove intermediate files, generate documentation. • The objective should be an automated tool that does all the work for you. Type or click one command and create a final product. • There are a couple of ways this can be done: – Write a batch file or script • The scripts tend to be hard to maintain – Use a tool designed for the task • Ant
  • 4. What is ANT • Java based free build tool from Apache - Build IN Java, USING Java, and FOR Java • ANT uses XML based configuration “Build” file to drive its actions. • To create powerful Ant build files to compile and bundle applications in .jar, .ear, or .war files, and to deploy J2EE software applications
  • 6. Why ANT • Written in Java so it’s a Cross-Platform build tool – Cross platform build files support developers working on different operating systems • Instead of writing shell commands, the configuration files are XML based which are easy to read and modify. • Faster since each command is executed from within JVM. • One-time setup hassle provides easy building of a project • Ant's Debug Options are very helpful
  • 7. Installing Ant • Download Ant binary distribution from: http://ant.apache.org/bindownload.cgi • Set ANT_HOME to where you installed Ant • Include $ANT_HOME/bin in PATH • Make sure JAVA_HOME is set to point to JDK • Assume Ant is installed in c:ant. The following sets up the environment: set ANT_HOME=c:ant set JAVA_HOME=c:j2sdk1.6.0_24 set PATH=%PATH%;%ANT_HOME%bin
  • 9. How ANT works • Each build file has exactly one project. • Each Build File is made up of at least one target. – Examples are: 'compile', ‘build', 'clean', etc. • Each Target is made up of Tasks – which are executed in a sequence • Targets can have Dependencies – Examples: 'install' depends on 'compile' – Can handle cascading dependencies – Each Dependency is handled only once
  • 10. Structure of BUILD File <?xml version="1.0"?> <project name="Ant-Test" default="main" basedir="."> <!-- Sets variables which can later be used. --> <!-- The value of a property is accessed via ${} --> <property name="src.dir" location="src" /> <property name="build.dir" location="bin" /> <property name="dist.dir" location="dist" /> <property name="docs.dir" location="docs" /> <!-- Deletes the existing build, docs and dist directory--> <target name="clean"> <delete dir="${build.dir}" /> <delete dir="${docs.dir}" /> <delete dir="${dist.dir}" /> </target> <!-- Creates the build, docs and dist directory--> <target name="makedir"> <mkdir dir="${build.dir}" /> <mkdir dir="${docs.dir}" /> <mkdir dir="${dist.dir}" /> </target>
  • 11. Structure of BUILD File Contd… <!-- Compiles the java code (including the usage of library for JUnit --> <target name="compile" depends="clean, makedir"> <javac srcdir="${src.dir}" destdir="${build.dir}"> </javac> </target> <!-- Creates Javadoc --> <target name="docs" depends="compile"> <javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}"> <!-- Define which files / directory should get included, we include all --> <fileset dir="${src.dir}"> <include name="**" /> </fileset> </javadoc> </target> <!--Creates the deployable jar file --> <target name="jar" depends="compile"> <jar destfile="${dist.dir}de.vogella.build.test.ant.jar" basedir="${build.dir}"> <manifest> <attribute name="Main-Class" value="test.Main" /> </manifest> </jar> </target> <target name="main" depends="compile, jar, docs"> <description>Main target</description> </target> </project>
  • 12. Useful Target Definitions  Init : Sets up properties that will be used throughout the build file. Properties can be set directly or by specifying a properties file.  Prepare : Create any directory structure which is needed.  Clean : clean is useful for enabling clean builds. Generally just deletes stuff from previous runs. (ant clean build)  Compile : Compile some/all of your source files in this target  Jar : Creates a jar file from the stuff you’ve built
  • 13. Tasks Contd… • javac - The javac task compiles Java source into class files,just as the javac command-line tool does. Ant will recompile only those files that have changed. • java - Execute a Java class • javadoc - Generates JavaDoc from your source files • jar (and war) - Create JAR files • mkdir - Makes a directory • copy - Copies files to specified location • exec - allows different commands to be executed based on the OS it is executing on.
  • 14. Tasks Contd… • delete - Deletes specified files • parallel - Runs two or more Ant tasks (not targets) simultaneously in separate threads • Import - Includes another build file into the current file • echo - Prints a message to the console (default) or a file • antcall - Calls another target within the same build file • ant - Calls another target on a different build file • FTP - lists, gets, puts and deletes files on an FTP server Note : You can also write your own tasks.
  • 15. Summary • Ant is a cross-platform build tool for Java. • Ant uses XML based configuration file typically named 'build.xml'. • Project, Targets and Tasks - A build.xml would contain 1 project with one or more targets and each of the target containing one or more tasks.