SlideShare une entreprise Scribd logo
1  sur  11
How to write a simple ANT build files for the Enterprise projects.
1/30/2015 Ravi Reddy (Ravinder Nancherla) 1
ANT Tutorials
 Tutorials How to write a build file for a simple Java project
Create a simple sample project in your eclipse IDE, Below is the screen shot and build script.
1/30/2015 Ravi Reddy (Ravinder Nancherla) 2
ANT Tutorials
 Build.xml
<project name="TestAnt" basedir="." default="run">
<!-- Clean Target -->
<target name="clean">
<delete dir="build"/>
</target>
<!-- Compile Target -->
<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>
<!-- Make JAR Target -->
<target name="jar">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/TestAnt.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="com.test.ant.EmployeeTestClient"/>
</manifest>
</jar>
</target>
<!-- Run JAR to execute the main class. -->
<target name="run">
<java jar="build/jar/TestAnt.jar" fork="true"/>
</target>
</project>
1/30/2015 Ravi Reddy (Ravinder Nancherla) 3
ANT Tutorials
 Tutorials How to write a build file for a simple Java Web project
Create a simple sample web project in your eclipse IDE, Below is the screen shot and
build script.
1/30/2015 Ravi Reddy (Ravinder Nancherla) 4
ANT Tutorials
 Build.xml
<?xml version="1.0"?>
<project name="AntTestForWebApp" default="buildWar" basedir=".">
<property name="baseDir" value="${basedir}" />
<property name="src" value="${baseDir}/src" />
<property name="webRoot" value="${baseDir}/WebRoot" />
<property name="warDir" value="${baseDir}/build/war" />
<property name="libDir" value="${warDir}/WEB-INF/lib" />
<path id="libClasspath">
<fileset dir="${webRoot}/WEB-INF/lib" includes="**/*.jar" />
</path>
<!-- ========================= **** Clean Target **** =========================-->
<target name="clean">
<delete dir="${baseDir}/build" />
</target>
<!-- ========================= **** Init Target **** =========================-->
<target name="init">
<!-- Create Web-INF,lib, classes, META-INF directories -->
<mkdir dir="${libDir}" />
<mkdir dir="${warDir}/WEB-INF" />
<mkdir dir="${warDir}/WEB-INF/classes" />
<mkdir dir="${warDir}/META-INF" />
</target>
1/30/2015 Ravi Reddy (Ravinder Nancherla) 5
ANT Tutorials
<!-- =================== **** COMPILE **** =======================================
Compile Java Files and place the following things in
1) *.classes files in WEB-INF/classes
2) *.jar files in WEB-INF/lib
3) web.xml in WEB-INF
4) *.jsp files in parent directory path build/war
================================================================================ -->
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${warDir}/WEB-INF/classes" debug="true" includes="**/*.java"
optimize="on">
<classpath refid="libClasspath" />
</javac>
<copy todir="${libDir}">
<fileset dir="${webRoot}/WEB-INF/lib" includes="**/*.jar" />
</copy>
<copy todir="${warDir}/WEB-INF">
<fileset dir="${webRoot}/WEB-INF" includes="web.xml" />
</copy>
<copy todir="${warDir}">
<fileset dir="${webRoot}" includes="*.jsp" />
</copy>
</target>
1/30/2015 Ravi Reddy (Ravinder Nancherla) 6
ANT Tutorials
<!-- ========================= **** Create the WAR File **** =========================-->
<target name="buildWar">
<!-- Option 1: Using <jar> create war file and place WAR file in BUILD directory -->
<!--
<jar jarfile="${baseDir}/build/AntTestForWebApp.war" basedir="${warDir}" />
-->
<!-- Option 2: Using <war> create war file and place WAR file in BUILD directory -->
<war destfile="${baseDir}/build/AntTestForWebApp.war" webxml="${warDir}/WEB-INF/web.xml">
<zipfileset dir="${warDir}"/>
</war>
</target>
</project>
1/30/2015 Ravi Reddy (Ravinder Nancherla) 7
ANT Tutorials
 Tutorials How to write a build file for a simple Java Web project
Create a simple sample EAR project in your eclipse IDE, Below is the screen
shot and build script.
1/30/2015 Ravi Reddy (Ravinder Nancherla) 8
ANT Tutorials
1/30/2015 Ravi Reddy (Ravinder Nancherla) 9
<?xml version = "1.0" encoding = "UTF-8"?>
<!-- ==========================================================================-->
<!-- Trying Build file for EAR Application -->
<!-- build.xml, Friday, August 27, 2010 -->
<!-- Author: Ravinder Nancherla -->
<!-- Email: ravinder.nancherla@gmail.com -->
<!-- Copyright(c) 2010 Ravinder Nancherla (Ravi Reddy)., All Rights Reserved. -->
<!-- ========================================================================= -->
<project name="AntEarWarJar" default="buildEar" basedir=".">
<property name="webModule" value="C:/SravanthiPractice/AntEarWarJarWeb"/>
<property name="ejbModule" value="C:/SravanthiPractice/AntEarWarJarEJB"/>
<property name="baseDir" value="${basedir}"/>
<property name="build" value="${baseDir}/build"/>
<property name="jarDir" value="${baseDir}/build/jar"/>
<property name="warDir" value="${baseDir}/build/war"/>
<property name="earDir" value="${baseDir}/build/ear"/>
<property name="webRootDir" value="${webModule}/WebRoot/WEB-INF"/>
<property name="webDir" value="${warDir}/WEB-INF"/>
<path id="libClasspath">
<fileset dir="${webRootDir}/lib" includes="**/*.jar" />
</path>
ANT Tutorials
<!-- Cleaning the build directory -->
<target name="clean">
<delete dir="${build}"/>
</target>
<!-- Initializing/Creating the directories -->
<target name="init" depends="clean">
<mkdir dir="${jarDir}/classes"/>
<mkdir dir="${jarDir}/jar"/>
<mkdir dir="${warDir}/META-INF"/>
<mkdir dir="${webDir}/classes"/>
<mkdir dir="${webDir}/lib"/>
<mkdir dir="${earDir}/META-INF"/>
</target>
<!-- Compiling and copying the files from EjbModule and WebModiule -->
<target name="compile" depends="init">
<javac srcdir="${ejbModule}/src" destdir="${jarDir}/classes" includes="**/*.java"/>
<javac srcdir="${webModule}/src" destdir="${webDir}/classes" includes="**/*.java">
<classpath refid="libClasspath"/>
</javac>
<copy todir="${webDir}/lib">
<fileset dir="${webRootDir}/lib" includes="**/*.jar"/>
</copy>
1/30/2015 Ravi Reddy (Ravinder Nancherla) 10
ANT Tutorials
<copy todir="${webDir}">
<fileset dir="${webRootDir}" includes="web.xml"/>
</copy>
<copy todir="${warDir}">
<fileset dir="${webModule}/WebRoot" includes="**/*.jsp"/>
</copy>
<copy todir="${earDir}/META-INF">
<fileset dir="${baseDir}/META-INF" includes="**/*.*"/>
</copy>
</target>
<!-- Creating Jar File -->
<target name="buildJar" depends="compile">
<jar jarfile="${earDir}/${ant.project.name}.jar" basedir="${jarDir}"/>
<jar jarfile="${jarDir}/jar/${ant.project.name}.jar" basedir="${jarDir}"/>
</target>
<!-- Creating War File -->
<target name="buildWar" depends="compile">
<jar jarfile="${earDir}/${ant.project.name}.war" basedir="${warDir}"/>
</target>
<!-- Creating Ear File -->
<target name="buildEar" depends="buildJar,buildWar">
<jar jarfile="${build}/${ant.project.name}.ear" basedir="${earDir}"/>
</target>
</project>
1/30/2015 Ravi Reddy (Ravinder Nancherla) 11

Contenu connexe

Tendances

Accessibility Testing using Axe
Accessibility Testing using AxeAccessibility Testing using Axe
Accessibility Testing using AxeRapidValue
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Jeado Ko
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projectsVincent Massol
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another buildIgor Khotin
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-kyon mm
 
C fowler azure-dojo
C fowler azure-dojoC fowler azure-dojo
C fowler azure-dojosdeconf
 
What the heck went wrong?
What the heck went wrong?What the heck went wrong?
What the heck went wrong?Andy McKay
 
Tackling Umbraco: Case Study on NFL Ops Website Design
Tackling Umbraco: Case Study on NFL Ops Website DesignTackling Umbraco: Case Study on NFL Ops Website Design
Tackling Umbraco: Case Study on NFL Ops Website Designmcampolongo
 
How to create a skeleton of a Java console application
How to create a skeleton of a Java console applicationHow to create a skeleton of a Java console application
How to create a skeleton of a Java console applicationDmitri Pisarenko
 
淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合Kyle Lin
 
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenBuilding Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenOliver Ochs
 

Tendances (14)

Accessibility Testing using Axe
Accessibility Testing using AxeAccessibility Testing using Axe
Accessibility Testing using Axe
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projects
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-
 
C fowler azure-dojo
C fowler azure-dojoC fowler azure-dojo
C fowler azure-dojo
 
What the heck went wrong?
What the heck went wrong?What the heck went wrong?
What the heck went wrong?
 
Tackling Umbraco: Case Study on NFL Ops Website Design
Tackling Umbraco: Case Study on NFL Ops Website DesignTackling Umbraco: Case Study on NFL Ops Website Design
Tackling Umbraco: Case Study on NFL Ops Website Design
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
 
How to create a skeleton of a Java console application
How to create a skeleton of a Java console applicationHow to create a skeleton of a Java console application
How to create a skeleton of a Java console application
 
Vuex
VuexVuex
Vuex
 
淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合
 
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenBuilding Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
 

Similaire à Tutorial to develop build files using ANT

Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache AntShih-Hsiang Lin
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guideducquoc_vn
 
Apache ant
Apache antApache ant
Apache antkoniik
 
OSGi framework overview
OSGi framework overviewOSGi framework overview
OSGi framework overviewBalduran Chang
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction SheetvodQA
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDocker, Inc.
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new buildIgor Khotin
 
Android secure offline storage - CC Mobile
Android secure offline storage - CC MobileAndroid secure offline storage - CC Mobile
Android secure offline storage - CC MobileSteve De Zitter
 
Android secure offline storage - CC Mobile
Android secure offline storage - CC MobileAndroid secure offline storage - CC Mobile
Android secure offline storage - CC MobileJWORKS powered by Ordina
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with MavenArcadian Learning
 
JavaZone 2015: Mine containere er lettere enn dine.
JavaZone 2015: Mine containere er lettere enn dine.JavaZone 2015: Mine containere er lettere enn dine.
JavaZone 2015: Mine containere er lettere enn dine.Anders Breivik
 

Similaire à Tutorial to develop build files using ANT (20)

Ant
AntAnt
Ant
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Build Scripts
Build ScriptsBuild Scripts
Build Scripts
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guide
 
Algotitmo Moinho
Algotitmo MoinhoAlgotitmo Moinho
Algotitmo Moinho
 
Apache ant
Apache antApache ant
Apache ant
 
OSGi framework overview
OSGi framework overviewOSGi framework overview
OSGi framework overview
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction Sheet
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
Intro to-ant
Intro to-antIntro to-ant
Intro to-ant
 
SBT Concepts, part 2
SBT Concepts, part 2SBT Concepts, part 2
SBT Concepts, part 2
 
Android secure offline storage - CC Mobile
Android secure offline storage - CC MobileAndroid secure offline storage - CC Mobile
Android secure offline storage - CC Mobile
 
Android secure offline storage - CC Mobile
Android secure offline storage - CC MobileAndroid secure offline storage - CC Mobile
Android secure offline storage - CC Mobile
 
Apache ant
Apache antApache ant
Apache ant
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
JavaZone 2015: Mine containere er lettere enn dine.
JavaZone 2015: Mine containere er lettere enn dine.JavaZone 2015: Mine containere er lettere enn dine.
JavaZone 2015: Mine containere er lettere enn dine.
 
Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
 
Ant build tool2
Ant   build tool2Ant   build tool2
Ant build tool2
 

Plus de ravireddy76

Groovy in SOAP UI
Groovy in SOAP UIGroovy in SOAP UI
Groovy in SOAP UIravireddy76
 
WID (Websphere Integration Development) Guide
WID (Websphere Integration Development) GuideWID (Websphere Integration Development) Guide
WID (Websphere Integration Development) Guideravireddy76
 
Richfaces Proto Type
Richfaces Proto TypeRichfaces Proto Type
Richfaces Proto Typeravireddy76
 
Icefaces Proto Type
Icefaces Proto TypeIcefaces Proto Type
Icefaces Proto Typeravireddy76
 

Plus de ravireddy76 (6)

Groovy in SOAP UI
Groovy in SOAP UIGroovy in SOAP UI
Groovy in SOAP UI
 
WID (Websphere Integration Development) Guide
WID (Websphere Integration Development) GuideWID (Websphere Integration Development) Guide
WID (Websphere Integration Development) Guide
 
Maven
MavenMaven
Maven
 
Flex Proto Type
Flex  Proto  TypeFlex  Proto  Type
Flex Proto Type
 
Richfaces Proto Type
Richfaces Proto TypeRichfaces Proto Type
Richfaces Proto Type
 
Icefaces Proto Type
Icefaces Proto TypeIcefaces Proto Type
Icefaces Proto Type
 

Dernier

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 

Dernier (20)

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 

Tutorial to develop build files using ANT

  • 1. How to write a simple ANT build files for the Enterprise projects. 1/30/2015 Ravi Reddy (Ravinder Nancherla) 1
  • 2. ANT Tutorials  Tutorials How to write a build file for a simple Java project Create a simple sample project in your eclipse IDE, Below is the screen shot and build script. 1/30/2015 Ravi Reddy (Ravinder Nancherla) 2
  • 3. ANT Tutorials  Build.xml <project name="TestAnt" basedir="." default="run"> <!-- Clean Target --> <target name="clean"> <delete dir="build"/> </target> <!-- Compile Target --> <target name="compile"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes"/> </target> <!-- Make JAR Target --> <target name="jar"> <mkdir dir="build/jar"/> <jar destfile="build/jar/TestAnt.jar" basedir="build/classes"> <manifest> <attribute name="Main-Class" value="com.test.ant.EmployeeTestClient"/> </manifest> </jar> </target> <!-- Run JAR to execute the main class. --> <target name="run"> <java jar="build/jar/TestAnt.jar" fork="true"/> </target> </project> 1/30/2015 Ravi Reddy (Ravinder Nancherla) 3
  • 4. ANT Tutorials  Tutorials How to write a build file for a simple Java Web project Create a simple sample web project in your eclipse IDE, Below is the screen shot and build script. 1/30/2015 Ravi Reddy (Ravinder Nancherla) 4
  • 5. ANT Tutorials  Build.xml <?xml version="1.0"?> <project name="AntTestForWebApp" default="buildWar" basedir="."> <property name="baseDir" value="${basedir}" /> <property name="src" value="${baseDir}/src" /> <property name="webRoot" value="${baseDir}/WebRoot" /> <property name="warDir" value="${baseDir}/build/war" /> <property name="libDir" value="${warDir}/WEB-INF/lib" /> <path id="libClasspath"> <fileset dir="${webRoot}/WEB-INF/lib" includes="**/*.jar" /> </path> <!-- ========================= **** Clean Target **** =========================--> <target name="clean"> <delete dir="${baseDir}/build" /> </target> <!-- ========================= **** Init Target **** =========================--> <target name="init"> <!-- Create Web-INF,lib, classes, META-INF directories --> <mkdir dir="${libDir}" /> <mkdir dir="${warDir}/WEB-INF" /> <mkdir dir="${warDir}/WEB-INF/classes" /> <mkdir dir="${warDir}/META-INF" /> </target> 1/30/2015 Ravi Reddy (Ravinder Nancherla) 5
  • 6. ANT Tutorials <!-- =================== **** COMPILE **** ======================================= Compile Java Files and place the following things in 1) *.classes files in WEB-INF/classes 2) *.jar files in WEB-INF/lib 3) web.xml in WEB-INF 4) *.jsp files in parent directory path build/war ================================================================================ --> <target name="compile" depends="init"> <javac srcdir="${src}" destdir="${warDir}/WEB-INF/classes" debug="true" includes="**/*.java" optimize="on"> <classpath refid="libClasspath" /> </javac> <copy todir="${libDir}"> <fileset dir="${webRoot}/WEB-INF/lib" includes="**/*.jar" /> </copy> <copy todir="${warDir}/WEB-INF"> <fileset dir="${webRoot}/WEB-INF" includes="web.xml" /> </copy> <copy todir="${warDir}"> <fileset dir="${webRoot}" includes="*.jsp" /> </copy> </target> 1/30/2015 Ravi Reddy (Ravinder Nancherla) 6
  • 7. ANT Tutorials <!-- ========================= **** Create the WAR File **** =========================--> <target name="buildWar"> <!-- Option 1: Using <jar> create war file and place WAR file in BUILD directory --> <!-- <jar jarfile="${baseDir}/build/AntTestForWebApp.war" basedir="${warDir}" /> --> <!-- Option 2: Using <war> create war file and place WAR file in BUILD directory --> <war destfile="${baseDir}/build/AntTestForWebApp.war" webxml="${warDir}/WEB-INF/web.xml"> <zipfileset dir="${warDir}"/> </war> </target> </project> 1/30/2015 Ravi Reddy (Ravinder Nancherla) 7
  • 8. ANT Tutorials  Tutorials How to write a build file for a simple Java Web project Create a simple sample EAR project in your eclipse IDE, Below is the screen shot and build script. 1/30/2015 Ravi Reddy (Ravinder Nancherla) 8
  • 9. ANT Tutorials 1/30/2015 Ravi Reddy (Ravinder Nancherla) 9 <?xml version = "1.0" encoding = "UTF-8"?> <!-- ==========================================================================--> <!-- Trying Build file for EAR Application --> <!-- build.xml, Friday, August 27, 2010 --> <!-- Author: Ravinder Nancherla --> <!-- Email: ravinder.nancherla@gmail.com --> <!-- Copyright(c) 2010 Ravinder Nancherla (Ravi Reddy)., All Rights Reserved. --> <!-- ========================================================================= --> <project name="AntEarWarJar" default="buildEar" basedir="."> <property name="webModule" value="C:/SravanthiPractice/AntEarWarJarWeb"/> <property name="ejbModule" value="C:/SravanthiPractice/AntEarWarJarEJB"/> <property name="baseDir" value="${basedir}"/> <property name="build" value="${baseDir}/build"/> <property name="jarDir" value="${baseDir}/build/jar"/> <property name="warDir" value="${baseDir}/build/war"/> <property name="earDir" value="${baseDir}/build/ear"/> <property name="webRootDir" value="${webModule}/WebRoot/WEB-INF"/> <property name="webDir" value="${warDir}/WEB-INF"/> <path id="libClasspath"> <fileset dir="${webRootDir}/lib" includes="**/*.jar" /> </path>
  • 10. ANT Tutorials <!-- Cleaning the build directory --> <target name="clean"> <delete dir="${build}"/> </target> <!-- Initializing/Creating the directories --> <target name="init" depends="clean"> <mkdir dir="${jarDir}/classes"/> <mkdir dir="${jarDir}/jar"/> <mkdir dir="${warDir}/META-INF"/> <mkdir dir="${webDir}/classes"/> <mkdir dir="${webDir}/lib"/> <mkdir dir="${earDir}/META-INF"/> </target> <!-- Compiling and copying the files from EjbModule and WebModiule --> <target name="compile" depends="init"> <javac srcdir="${ejbModule}/src" destdir="${jarDir}/classes" includes="**/*.java"/> <javac srcdir="${webModule}/src" destdir="${webDir}/classes" includes="**/*.java"> <classpath refid="libClasspath"/> </javac> <copy todir="${webDir}/lib"> <fileset dir="${webRootDir}/lib" includes="**/*.jar"/> </copy> 1/30/2015 Ravi Reddy (Ravinder Nancherla) 10
  • 11. ANT Tutorials <copy todir="${webDir}"> <fileset dir="${webRootDir}" includes="web.xml"/> </copy> <copy todir="${warDir}"> <fileset dir="${webModule}/WebRoot" includes="**/*.jsp"/> </copy> <copy todir="${earDir}/META-INF"> <fileset dir="${baseDir}/META-INF" includes="**/*.*"/> </copy> </target> <!-- Creating Jar File --> <target name="buildJar" depends="compile"> <jar jarfile="${earDir}/${ant.project.name}.jar" basedir="${jarDir}"/> <jar jarfile="${jarDir}/jar/${ant.project.name}.jar" basedir="${jarDir}"/> </target> <!-- Creating War File --> <target name="buildWar" depends="compile"> <jar jarfile="${earDir}/${ant.project.name}.war" basedir="${warDir}"/> </target> <!-- Creating Ear File --> <target name="buildEar" depends="buildJar,buildWar"> <jar jarfile="${build}/${ant.project.name}.ear" basedir="${earDir}"/> </target> </project> 1/30/2015 Ravi Reddy (Ravinder Nancherla) 11