TJR
TJR

Reputation: 3773

Is there a quick way to export a WAR file in Eclipse 3.4?

I know about the export->war file

I would like something similar to the .jardesc that allows you to define the destination. So I could right-click on that .jardesc and do export. Except .wardesc instead of .jardesc :)

Is the war export functionality tied to an eclipse ant task?

I've put together an AHK macro so it will do the GUI motions for me... but that's a hack not a solution.

Upvotes: 4

Views: 4961

Answers (5)

John Ellinwood
John Ellinwood

Reputation: 14531

Theres the Ant WAR task.

Upvotes: 1

Tomasz
Tomasz

Reputation: 5539

WAR ant task

http://ant.apache.org/manual/Tasks/war.html

from the documentation:

Assume the following structure in the project's base directory:

thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif

then the war file myapp.war created with

<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
  <fileset dir="src/html/myapp"/>
  <fileset dir="src/jsp/myapp"/>
  <lib dir="thirdparty/libs">
    <exclude name="jdbc1.jar"/>
  </lib>
  <classes dir="build/main"/>
  <zipfileset dir="src/graphics/images/gifs"
              prefix="images"/>
</war>

will consist of

WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif

Upvotes: 0

lothar
lothar

Reputation: 20257

Eclipse has the notion of external commands. If you can write e.g. an ant script that does the export the way you like it you can start it from the menu/button. For ant scripts you can also pick the ant target you want to call and pass properties. This allows you to edit e.g. the path name in the Launch Configuration.

Upvotes: 0

mhaller
mhaller

Reputation: 14222

The right way to do "war export" is to use a build system (like Maven) and let it do the heavy lifting. All you need is a pom.xml with <packaging>war</packaging>.

Eclipse's exports are meant for occasional exports by humans, not for automation. And if you would really like to automate, do it right. You will benefit from other things, too. The same pom file will run on your machine, on other developers' machines and on your build server.

Upvotes: 0

Nik Reiman
Nik Reiman

Reputation: 40430

Is the war export functionality tied to an eclipse ant task?

As far as I know, yes. You might try searching for a plugin that can do this for you; I found a couple, such as the war-plugin builder, but I haven't tried it myself, as I try to avoid using extra plugins in eclipse.

Upvotes: 2

Related Questions