Skip to main content

Module Suite building tips (part 2)

Posted by richunger on December 19, 2005 at 6:38 PM PST

I think I'm one of the first people to make a netbeans module suite with a large number of modules, so as a followup to my last entry on module suite building, I thought I'd continue putting up some of my build script hacks.

The problem I'm solving here is in having a canonical netbeans platform to build against. Up until now, I've been building against the IDE, from within the IDE. That works very well, but now I'm ready to set up my nightly build process, and I want to make sure that the nightly builds use the exact same netbeans platform that I use in development.

I start off by editing my suite's nbproject/ file:


This means that the build scripts will expect an installation of the netbeans platform (including the harness/ directory) to be in ${MySourceRoot}/image/netbeans

I've also downloaded a zip file of netbeans 5.0 and checked it into my source tree, to be unzipped automatically by my build scripts.

My first thought was just to have the ant script's "init" target unzip the file. The problem with that is that the file must be unzipped in order to provide the harness/ expected by ${harness.dir}. This is necessary to build the list of s in the build file. So, the unzipping must occur before importing build-impl.xsl and building the targets.

This makes it difficult to unzip the platform conditionally. I don't want to unzip it if it's already unzipped. However, the only way to do conditionals in ant is to use the 'unless' attribute in . But, I need to unzip the platform in order to build the targets!

ant-contrib to the rescue.

My suite's build.xml file looks like this:

<project name="vbuilder" basedir=".">
    <description>Builds the module suite vbuilder.</description>

    <!-- Need ant-contrib because of the element -->
    <taskdef resource="net/sf/antcontrib/antlib.xml">
            <pathelement location="${basedir}/nbproject/ant-contrib.jar"/>

    <!-- This needs to come before the import of build-impl.
         The must be unzipped to provide the build harness,
         _before_ creating <target>s.  Therefore, this cannot be done
         with the 'unless' attribute of <target>
            <available file="image/netbeans"/>
            <mkdir dir="image"/>
            <unzip src="" dest="image"/>

    <import file="nbproject/build-impl.xml"/>

One last note. This will not work in 5.0 beta2, only in later development builds (it will work in 5.0 final). This is because ${netbeans.dest.dir} is a relative path.

The workaround for beta2 is to add this line to

zip.platform.clusters.duplicates=platform6,ide6,nb5.0,enterprise2 it the list of clusters from the netbeans platform you wish to include in your application.