SlideShare une entreprise Scribd logo
1  sur  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’

Contenu connexe

Tendances

JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发
 

Tendances (20)

JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Express js
Express jsExpress js
Express js
 
Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript Programming
 
Spring boot
Spring bootSpring boot
Spring boot
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsReact-JS Component Life-cycle Methods
React-JS Component Life-cycle Methods
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
 
Servlets
ServletsServlets
Servlets
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Dernier

Dernier (20)

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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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...
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
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
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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
 
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
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

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.