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?

Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 

Was ist angesagt? (20)

Spring Data JPA
Spring Data JPASpring Data JPA
Spring Data JPA
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New Features
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
React js
React jsReact js
React js
 
Les dessous du framework spring
Les dessous du framework springLes dessous du framework spring
Les dessous du framework spring
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Spring boot
Spring bootSpring boot
Spring boot
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured framework
 
Introdução ao React
Introdução ao ReactIntrodução ao React
Introdução ao React
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and files
 

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
 
Ant tutorial
Ant tutorialAnt tutorial
Ant tutorial
 
Java ant tutorial
Java ant tutorialJava ant tutorial
Java 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

Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Kürzlich hochgeladen (20)

Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 

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.