SlideShare une entreprise Scribd logo
1  sur  8
Ali Bahu
12/24/2012
APACHE ANT
INTRODUCTION
 A build tool can be used to automate certain repetitive tasks for
example compiling source code, running software tests and
creating files and documentation for the software deployment.
 Build tools typically run without a graphical user interface.
 Popular build tools used by Java developers are Apache Ant and
Maven.
APACHE ANT OVERVIEW
 Apache Ant (Ant) is a general purpose build tool. Ant is an abbreviation for
“Another Neat Tool”.
 Ant is primarily used for building and deploying Java projects.
 A Java build process typically includes:
 the compilation of the Java source code into Java bytecode
 creation of the .jar file for the distribution of the code
 creation of the Javadoc documentation
 Ant uses an xml file for its configuration. This file is usually called build.xml.
Ant builds are based on three blocks: tasks, targets and extension points.
 A task is a unit of work which should be performed and are small, atomic
steps, for example compile source code or create Javadoc. Tasks can be
grouped into targets.
 A target can be directly invoked via Ant. Targets can specify their
dependencies. Ant will automatically execute dependent targets. For example
if target A depends on B, than Ant will first perform B and then A. You can
specify the default target in your build.xml file. Ant will execute this target, if
no explicit target is specified.
HOW TO USE APACHE ANT
 Create a Java Project called com.fedex.build.ant.first in Eclipses.
Create a package called test.
package test;
public class MyTest
{
public int multi(int number1, int number2)
{
return number1 * number2;
}
}
package test;
import test.MyTest;
public class Main
{
public static void main(String[] args) {
MyTest test = new MyTest();
System.out.println("Result is: " + test.multi(5,
10));
}
}
CREATE BUILD.XML FILE & RUN FROM
ECLIPSE
 Click on the build.xml file to review and understand it.
 Running from Eclipse i.e.
 Running From Command Line:
Open a command line and switch
to your project directory. Type in
"ant" or "ant -f build.xml" to start
the build process.
APACHE ANT CLASSPATH
 Ant also allows to create classpath containers and use them in
tasks. The following build_classpath.xml from a project called
com.fedex.build.ant.classpath demonstrates this concept:
 To print the classpath for debugging:
<!-- Write the classpath to the console. Helpful for debugging -->
<!-- Create one line per classpath element-->
<pathconvert pathsep="${line.separator}" property="echo.classpath" refid="junit.class.path">
</pathconvert>
<!-- Write the result to the console -->
<echo message="The following classpath is associated with junit.class.path" />
<echo message="${echo.classpath}" />
RUNNING JUNITS VIA ANT
 Ant allows to run JUnit tests. Ant defines JUnit task. You only need to
include the junit.jar and the compiled classes into the classpath for
Ant and then you can run JUnit tests. Below is an example:
 You can run this JUnit unit test via the following build_junit.xml. This
example assumes that the JUnit jar "junit.jar" is located in “lib” folder.
package test;
import math.MyMath;
import org.junit.Test;
import static
org.junit.Assert.assertEquals;
public class MyMathTest {
@Test
public void testMulti() {
MyMath math = new MyMath();
assertEquals(50, math.multi(5, 10));
}
}
ANT TIPS
 Eclipse has an ant editor which make the editing of ant file very easy by
providing syntax checking of the build file. Eclipse has also a ant view. In this
view you execute ant files via double-clicking on the target.
 Apache Ant allows to convert relative paths to absolute paths i.e.
<property name="my.config" value="../my-config.xml"/>
<makeurl file="${my.config}" property="my.config.url"/>
 Ant can be used to replace text based on regular expressions i.e.
<target name="regular-expressions">
<!-- Replace tabs with two spaces -->
<replaceregexp flags="gs">
<regexp pattern="(t)" />
<substitution expression=" " />
<fileset dir="${outputtmp.dir}/">
<include name="**/*" /> </fileset>
</replaceregexp>
</target>

Contenu connexe

Tendances

EclipseMAT
EclipseMATEclipseMAT
EclipseMAT
Ali Bahu
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
Kanika2885
 

Tendances (19)

EclipseMAT
EclipseMATEclipseMAT
EclipseMAT
 
Apache ant
Apache antApache ant
Apache ant
 
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
 
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
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
 
Introduction To Ant1
Introduction To  Ant1Introduction To  Ant1
Introduction To Ant1
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 
dJango
dJangodJango
dJango
 
Deploy Flex with Apache Ant
Deploy Flex with Apache AntDeploy Flex with Apache Ant
Deploy Flex with Apache Ant
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...
 
RSpec 3.0: Under the Covers
RSpec 3.0: Under the CoversRSpec 3.0: Under the Covers
RSpec 3.0: Under the Covers
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 

En vedette

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 (16)

ANT
ANTANT
ANT
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and 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

Comparative Development Methodologies
Comparative Development MethodologiesComparative Development Methodologies
Comparative Development Methodologies
elliando dias
 
Jack borden jb471909_junit1
Jack borden jb471909_junit1Jack borden jb471909_junit1
Jack borden jb471909_junit1
jborden33
 
Jack borden jb471909_junit
Jack borden jb471909_junitJack borden jb471909_junit
Jack borden jb471909_junit
jborden33
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
sotlsoc
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
Greg.Helton
 
Integrate UFT with Jenkins Guide
Integrate UFT with Jenkins GuideIntegrate UFT with Jenkins Guide
Integrate UFT with Jenkins Guide
Yu Tao Zhang
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
Priya Sharma
 

Similaire à Apache Ant (20)

Comparative Development Methodologies
Comparative Development MethodologiesComparative Development Methodologies
Comparative Development Methodologies
 
Java ant tutorial
Java ant tutorialJava ant tutorial
Java ant tutorial
 
Database Management Assignment Help
Database Management Assignment Help Database Management Assignment Help
Database Management Assignment Help
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactus
 
N Unit Presentation
N Unit PresentationN Unit Presentation
N Unit Presentation
 
8-testing.pptx
8-testing.pptx8-testing.pptx
8-testing.pptx
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Maven and j unit introduction
Maven and j unit introductionMaven and j unit introduction
Maven and j unit introduction
 
Jack borden jb471909_junit1
Jack borden jb471909_junit1Jack borden jb471909_junit1
Jack borden jb471909_junit1
 
Jack borden jb471909_junit
Jack borden jb471909_junitJack borden jb471909_junit
Jack borden jb471909_junit
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Integrate UFT with Jenkins Guide
Integrate UFT with Jenkins GuideIntegrate UFT with Jenkins Guide
Integrate UFT with Jenkins Guide
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 

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@
 

Dernier (20)

+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...
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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...
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
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
 
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
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
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...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 

Apache Ant

  • 2. INTRODUCTION  A build tool can be used to automate certain repetitive tasks for example compiling source code, running software tests and creating files and documentation for the software deployment.  Build tools typically run without a graphical user interface.  Popular build tools used by Java developers are Apache Ant and Maven.
  • 3. APACHE ANT OVERVIEW  Apache Ant (Ant) is a general purpose build tool. Ant is an abbreviation for “Another Neat Tool”.  Ant is primarily used for building and deploying Java projects.  A Java build process typically includes:  the compilation of the Java source code into Java bytecode  creation of the .jar file for the distribution of the code  creation of the Javadoc documentation  Ant uses an xml file for its configuration. This file is usually called build.xml. Ant builds are based on three blocks: tasks, targets and extension points.  A task is a unit of work which should be performed and are small, atomic steps, for example compile source code or create Javadoc. Tasks can be grouped into targets.  A target can be directly invoked via Ant. Targets can specify their dependencies. Ant will automatically execute dependent targets. For example if target A depends on B, than Ant will first perform B and then A. You can specify the default target in your build.xml file. Ant will execute this target, if no explicit target is specified.
  • 4. HOW TO USE APACHE ANT  Create a Java Project called com.fedex.build.ant.first in Eclipses. Create a package called test. package test; public class MyTest { public int multi(int number1, int number2) { return number1 * number2; } } package test; import test.MyTest; public class Main { public static void main(String[] args) { MyTest test = new MyTest(); System.out.println("Result is: " + test.multi(5, 10)); } }
  • 5. CREATE BUILD.XML FILE & RUN FROM ECLIPSE  Click on the build.xml file to review and understand it.  Running from Eclipse i.e.  Running From Command Line: Open a command line and switch to your project directory. Type in "ant" or "ant -f build.xml" to start the build process.
  • 6. APACHE ANT CLASSPATH  Ant also allows to create classpath containers and use them in tasks. The following build_classpath.xml from a project called com.fedex.build.ant.classpath demonstrates this concept:  To print the classpath for debugging: <!-- Write the classpath to the console. Helpful for debugging --> <!-- Create one line per classpath element--> <pathconvert pathsep="${line.separator}" property="echo.classpath" refid="junit.class.path"> </pathconvert> <!-- Write the result to the console --> <echo message="The following classpath is associated with junit.class.path" /> <echo message="${echo.classpath}" />
  • 7. RUNNING JUNITS VIA ANT  Ant allows to run JUnit tests. Ant defines JUnit task. You only need to include the junit.jar and the compiled classes into the classpath for Ant and then you can run JUnit tests. Below is an example:  You can run this JUnit unit test via the following build_junit.xml. This example assumes that the JUnit jar "junit.jar" is located in “lib” folder. package test; import math.MyMath; import org.junit.Test; import static org.junit.Assert.assertEquals; public class MyMathTest { @Test public void testMulti() { MyMath math = new MyMath(); assertEquals(50, math.multi(5, 10)); } }
  • 8. ANT TIPS  Eclipse has an ant editor which make the editing of ant file very easy by providing syntax checking of the build file. Eclipse has also a ant view. In this view you execute ant files via double-clicking on the target.  Apache Ant allows to convert relative paths to absolute paths i.e. <property name="my.config" value="../my-config.xml"/> <makeurl file="${my.config}" property="my.config.url"/>  Ant can be used to replace text based on regular expressions i.e. <target name="regular-expressions"> <!-- Replace tabs with two spaces --> <replaceregexp flags="gs"> <regexp pattern="(t)" /> <substitution expression=" " /> <fileset dir="${outputtmp.dir}/"> <include name="**/*" /> </fileset> </replaceregexp> </target>