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

Apache ant
Apache antApache ant
Apache antkoniik
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache AntShih-Hsiang Lin
 
Introduction To Ant1
Introduction To  Ant1Introduction To  Ant1
Introduction To Ant1Rajesh Kumar
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring BootTrey Howard
 
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 ResultsSteve Keener
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driverPankaj Biswas
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparisonManav Prasad
 
Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practiceseleksdev
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?Robert Munteanu
 
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...Robert Munteanu
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010Rich Helton
 
Springboot introduction
Springboot introductionSpringboot introduction
Springboot introductionSagar Verma
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
 

Tendances (18)

Apache ant
Apache antApache ant
Apache ant
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Introduction To Ant1
Introduction To  Ant1Introduction To  Ant1
Introduction To Ant1
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
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
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driver
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
 
Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practices
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?
 
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...
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Adobe Flex4
Adobe Flex4 Adobe Flex4
Adobe Flex4
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
 
Springboot introduction
Springboot introductionSpringboot introduction
Springboot introduction
 
Mongo db
Mongo dbMongo db
Mongo db
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
 

En vedette (7)

Apache Ant
Apache AntApache Ant
Apache Ant
 
ANT
ANTANT
ANT
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Apache ANT
Apache ANTApache ANT
Apache ANT
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
 
Maven의 이해
Maven의 이해Maven의 이해
Maven의 이해
 
젠킨스 설치 및 설정
젠킨스 설치 및 설정젠킨스 설치 및 설정
젠킨스 설치 및 설정
 

Similaire à Apache Ant

Comparative Development Methodologies
Comparative Development MethodologiesComparative Development Methodologies
Comparative Development Methodologieselliando dias
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactusHimanshu
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
Maven and j unit introduction
Maven and j unit introductionMaven and j unit introduction
Maven and j unit introductionSergii Fesenko
 
Jack borden jb471909_junit1
Jack borden jb471909_junit1Jack borden jb471909_junit1
Jack borden jb471909_junit1jborden33
 
Jack borden jb471909_junit
Jack borden jb471909_junitJack borden jb471909_junit
Jack borden jb471909_junitjborden33
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnitGreg.Helton
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCFAKHRUN NISHA
 
Integrate UFT with Jenkins Guide
Integrate UFT with Jenkins GuideIntegrate UFT with Jenkins Guide
Integrate UFT with Jenkins GuideYu Tao Zhang
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and DebuggingRich Helton
 
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 2015Buşra Deniz, CSM
 

Similaire à Apache Ant (20)

Comparative Development Methodologies
Comparative Development MethodologiesComparative Development Methodologies
Comparative Development Methodologies
 
Ant tutorial
Ant tutorialAnt tutorial
Ant tutorial
 
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
 

Dernier

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 

Dernier (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 

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>