Learning about Build Targets in NetBeans IDE 4.1

I realized that having a single menu item for two different actions (deploying to JBoss and deploying to Tomcat 4) is a bit counter-intuitive. Each time I needed to change servers, I had to change properties so that the target would work for the appropriate server. So, I decided to create separate deployment targets. This meant that I also had to create separate targets for building the application -- if I want to deploy to JBoss, I want to build my application to a JBoss-specific directory and if I want to deploy to Tomcat 4, I want to build my application to a Tomcat-4 specific directory. So, this is my build target for Tomcat 4:

 <target name="aaa_Build-To-Tomcat4" description="Build to Tomcat4">
       <copy todir="${build.classes.dir.tomcat4}">
            <fileset dir="${src.root}" excludes="${build.classes.excludes.tomcat4}"/>
       </copy>
       <copy todir="${build.web.dir.tomcat4}">
            <fileset dir="${web.root}" excludes="${build.web.excludes.tomcat4}" />
       </copy>
 </target>
And my deploy target is still as follows:

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

And they use the following properties:

#The Tomcat 4 directory where everything is copied to:
 build.dir.tomcat4=c:/Program Files/Apache Group/Tomcat 4.1/webapps/${ant.project.name}

#The Java classes, where they go, and what to exclude:
 src.root=src/java
 build.classes.dir.tomcat4=${build.dir.tomcat4}/WEB-INF/classes
 build.classes.excludes.tomcat4=\*\*/\*.java,\*\*/\*.form

#The web files, where they go, and what to exclude:
 web.root=web
 build.web.dir.tomcat4=${build.dir.tomcat4}
 build.web.excludes.tomcat4=${build.classes.excludes.tomcat4}

#Port number:
 port.number.tomcat4=8085
The key to the whole puzzle was discovering that ant.project.name gets the project's name (which is set in project.xml). What is also pretty cool is that the IDE can generate a build script for you, which means that you can see how it is structured, so that you can create one yourself, even if you are a complete novice in Ant, like me...

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

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.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today