views:

4862

answers:

5

I have a J2EE project in Eclipse 3.2 and at the end of every build I want to automatically create and deploy a WAR file. At the moment I have to do this by hand which is 5 or 6 mouse-cliks and it would be nice to automate it.

I know I can do this with a custom build script using ANT but I am hoping for an Eclipse native solution.

I have the J2EE standard tools (JST) and Web Standard Tools (WST) plug-ins installed in my Eclipse environment.

A: 

There are only two options:

  • Or you right click on project: Run -> Run on server. (Your project needs to be a web project.)
  • Or you write that ant script and use eclipse to store you ant run configuration and reuse that config.
Loki
+5  A: 

If you can implement it as an Ant script, then you can have Eclipse invoke that Ant script on each build automatically (and inside the Eclipse environment). Use Project->Properties->Builders->Add->Ant Builder. Give that builder you custom Ant script and it will automatically be executed after the "normal" builders of your project.

Bananeweizen
I bit the bullet and wrote myself an ANT script. It's pretty weird that you can do the same thing from the menus via Export | WAR but have to use a 3rd party tool to script it into a build. Ah well.
Simon
I think the export you are referring to is baked into the WTP tools. Ant (or Maven) is the best option to automate Java builds.
Luke
A: 

Right click on your project: Export -> Web -> WAR File Do what you want to do.

A: 

Consider using netbeans, full ear and war deployment is possible without the need to write ant yourself for most of the major servers, ie tomcat, was, weblogic, glassfish and jboss.

I highly recommend it, even over the IBM rational suite.

Karl

Karl
A: 

Using the latest eclipse jee release you could define Servers and attach project to those servers.

This will automatically deploy your project to the server when the project changes.

TJ
Could you please provide full details for this in http://stackoverflow.com/questions/1108938/how-to-have-eclipse-jee-automatically-generate-the-war-for-a-web-project ? Would be very helpful!
Thorbjørn Ravn Andersen