Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Tutorial to develop build files using ANT

on

  • 5,760 views

Tutorial to develop build files using ANT

Tutorial to develop build files using ANT

Statistics

Views

Total Views
5,760
Views on SlideShare
5,266
Embed Views
494

Actions

Likes
0
Downloads
76
Comments
0

18 Embeds 494

http://ravireddyjsf.blogspot.com 231
http://www.ravireddyjsf.blogspot.com 136
http://ravireddyjsf.blogspot.in 54
http://ravireddyjsf.blogspot.ru 24
http://www.ravireddyjsf.blogspot.in 18
http://ravireddyjsf.blogspot.co.uk 9
http://www.linkedin.com 4
http://www.ravireddyjsf.blogspot.com.br 4
http://ravireddyjsf.blogspot.com.es 3
http://ravireddyjsf.blogspot.de 2
http://ravireddyjsf.blogspot.fr 2
http://ravireddyjsf.blogspot.nl 1
http://ravireddyjsf.blogspot.sg 1
http://www.ravireddyjsf.blogspot.fr 1
http://ravireddyjsf.blogspot.com.br 1
http://ravireddyjsf.blogspot.co.nz 1
http://ravireddyjsf.blogspot.ca 1
https://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Tutorial to develop build files using ANT Tutorial to develop build files using ANT Presentation Transcript

    • Tutorial For ANT Build Files
      How to write a simple ANT build files for the Enterprise projects.
      11/7/2010
      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.
      11/7/2010
      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"/>
      <javacsrcdir="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>
      11/7/2010
      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.
      11/7/2010
      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>
      11/7/2010
      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">
      <javacsrcdir="${src}" destdir="${warDir}/WEB-INF/classes" debug="true" includes="**/*.java" optimize="on">
      <classpathrefid="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>
      11/7/2010
      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>
      11/7/2010
      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.
      11/7/2010
      Ravi Reddy (Ravinder Nancherla)
      8
    • ANT Tutorials
      11/7/2010
      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: RavinderNancherla -->
      <!-- Email: ravinder.nancherla@gmail.com -->
      <!-- Copyright(c) 2010 RavinderNancherla (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">
      <javacsrcdir="${ejbModule}/src" destdir="${jarDir}/classes" includes="**/*.java"/>
      <javacsrcdir="${webModule}/src" destdir="${webDir}/classes" includes="**/*.java">
      <classpathrefid="libClasspath"/>
      </javac>
      <copy todir="${webDir}/lib">
      <fileset dir="${webRootDir}/lib" includes="**/*.jar"/>
      </copy>
      11/7/2010
      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>
      11/7/2010
      Ravi Reddy (Ravinder Nancherla)
      11