0% found this document useful (0 votes)
117 views

Build

The document provides code examples for creating a Build.xml file in Eclipse to define Ant build targets for cleaning files, creating a .war file, and deploying the .war file. It explains that the Build.xml file can be exported from a project in Eclipse and describes the purpose and structure of code blocks for the <target>, <delete>, <fileset>, <include>, <exclude>, <war>, and <copy> tags to configure cleaning files, packaging files into a .war, and deploying the .war to a Tomcat server.

Uploaded by

api-27399718
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

Build

The document provides code examples for creating a Build.xml file in Eclipse to define Ant build targets for cleaning files, creating a .war file, and deploying the .war file. It explains that the Build.xml file can be exported from a project in Eclipse and describes the purpose and structure of code blocks for the <target>, <delete>, <fileset>, <include>, <exclude>, <war>, and <copy> tags to configure cleaning files, packaging files into a .war, and deploying the .war to a Tomcat server.

Uploaded by

api-27399718
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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.

You might also like