Anda di halaman 1dari 2

Build.

xml

To create Build.xml in eclipse, select File- Exports, a popup window is opened select Ant
Buildfiles and click next button, then select the project and click finish. Now you can see
build.xml file.

Code for Clean:-

<target name="clean">
<delete>
<fileset dir="E:/USC/workspace/USC_ERP_RECKON">
<include name="**/*.class"/>
<exclude name="**/*.properties"/>
</fileset>
</delete>
<delete dir="work"/>
</target>

• In the target tag we will give the name.


• In delete tag we will specify what we want to delete (clean).
• In Fileset tag we give the specified path, from where we want to perform our
cleaning operations.
• In include tag we will specify all the files which we want to delete (clean).
• In exclude tag we will specify all the files which we don’t want to delete (clean).

Code for .war file:-

<target name="war" depends="build">


<war destfile="E:/USC/workspace/USC_ERP_RECKON/usc1.war"
webxml="E:/USC/workspace/USC_ERP_RECKON/WEB-INF/web.xml">
<fileset dir="E:/USC/workspace/USC_ERP_RECKON">
<exclude name="**/*.jar"/>
<exclude name="**/*.class"/>
<exclude name="**/*.properties"/>
<exclude name="**/web.xml"/>
</fileset>
<classes dir="E:/USC/workspace/USC_ERP_RECKON/WEB-
INF/classes" includes="**/*.class"/>
</war>
</target>

• In the target tag we will give the name for the war file. And in the depends, we
have to specify on which the war file is depended on, here it is depending on
compilation.
• In war tag we will specify destfile & webxml. At destfile we give the path where
we want to store our war file and at webxml we will give the path of web.xml.
• In Fileset tag we give the specified path, from where we want to perform our
operations.
• In exclude tag we will specify all the files which we don’t want to include in the
creation of war file.
• In the classes tag we will give the path of the classes directory.

Code for deploying war file:-

<target name="deploy">
<copy todir="C:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps">
<fileset dir="E:/USC/workspace/USC_ERP_RECKON" includes="usc103.war"/>
</copy>
</target>

• In the target tag we will give the name as deploy.


• In the copy tag, at todir we will give the Tomcat server’s webapp directory path,
where we want to place the created war file.
• In fileset tag, we will give the path from where we have to copy the war file.
• In the includes tag, we will give the name of the war file.

Anda mungkin juga menyukai