?
Solved

How to create war file in eclipse using ant

Posted on 2010-01-12
3
Medium Priority
?
1,462 Views
Last Modified: 2013-11-10
Hi,
I have created a web application in my my eclipse environment. In my eclipse I am running it with tomcat. I need to build a war file which I then can deploy on tomcat server which is on solaris box.

Attached document has a directory structure

Thanks
directoryStructure.jpg
0
Comment
Question by:AjooAli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
him6ul earned 2000 total points
ID: 26299609
Ant has a WAR task which you can use to create your WAR file.

Not sure why you want to use eclipse if you are anyways using ANT to create WAR - eclipse has task to call an ant file from IDE itself.
0
 
LVL 2

Expert Comment

by:malaki12003
ID: 26300466
Create an ANT script that will look at the Eclipse Project structure and build the WAR file and copy over the WAR file to the destination (Tomcat WebApps folder)

Here is the ANT script:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Deploy From Eclipse to Tomcat" basedir=".">
<property name="warfile" value="sanfran"/>
<target name="unpack">
<unwar src="${warfile}.war" dest="${warfile}" />
</target>
<target name="create">
<war destfile="${warfile}.war" webxml="WebContent/WEB-INF/web.xml" update="true">
<classes dir="build\classes"/>
<fileset dir="WebContent">
<exclude name="WEB-INF/web.xml"/>
</fileset>
</war>
</target>
<target name="copy">
<copy todir="c:\tomcat5517\webapps" overwrite="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="deploy">
<antcall target="create"/>
<antcall target="copy"/>
</target>
</project>

Save the above code into a file and name it build.xml. Place the build.xml into the root folder of your eclipse project. For example, if c:\projects is my eclipse workspace and SanFrancisco is the name of my project then all the files related to the project will be under c:\projects\SanFrancisco.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 26300552
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question