Tomcat 4, JBoss, and Ant in the NetBeans IDE

So now I have an Ant properties file with the following content:

# Tomcat 4
#build.web.dir=c:/Program Files/Apache Group/Tomcat 4.1/webapps/${}

# JBoss
And my Ant script contains one target:

<target name="aaa_Deploy-To-Tomcat4-or-JBoss" description="Deploy to Tomcat 4 or JBoss">
  <nbbrowse url="http://localhost:${port.number}/${}"/>

When I import (1) the Ant script containing this target and (2) the file defining the target's properties into a NetBeans IDE project's build.xml file (or whatever the local Ant build file is called), I only have to change the handful of properties in the external Ant file's properties file to be able to deploy to either Tomcat 4 or JBoss, after building the project to the build.web.dir applicable to the server in question. (Of course, I also have targets that start and stop Tomcat 4 and JBoss, but these are IDE-wide targets.) This is how I import the Ant script and properties file (they're both in a folder called "IDETargets", which is a different folder to where my IDE projects are stored -- by storing my re-usable targets in a separate folder I'm protecting them from my occasional over-zealous deletions):

<import file="../../IDETargets/ProjectAntTargets/project-specific-targets.xml"/>
<property file="../../IDETargets/ProjectAntTargets/nbproject/"/>

Here are the 1000 words in a picture:

The cool thing about this is that I now have a separate Ant script that contains all the information I need for deploying to Tomcat 4 or JBoss. Whenever I create a new web application, all I need to do is import the external Ant script and properties file into the new web application's own Ant script, tweak the properties in the external Ant script's properties file, and that's all. No deployment-related information is defined within an individual NetBeans IDE project, and so nothing is lost (and everything is re-usable) when I delete/lose/break an individual NetBeans IDE project.


THANK YOU!!! You have really saved me a lot of time. Using Netbeans plus JBOSS is a big big pain as JBOSS takes its own sweet time to redeploy the war file. Your technique is a real good way to achieve what I wanted!!. - Sunit

Posted by Sunit on April 20, 2006 at 05:32 PM PDT #

Good to know, Sunit, thanks! Very interesting that you're using this technique in NetBeans IDE 5.0, instead of the JBoss support in that release. But I can see your point. Ant is just so much simpler and more lightweight than dealing with a server for (re)deployment.

Posted by Geertjan on April 20, 2006 at 07:17 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« April 2014