Skip to main content

New improvements for building NetBeans RCP apps - and OpenBlueSky available

Posted by fabriziogiudici on November 18, 2007 at 1:19 PM PST

After some refactoring, I've polished my ant tools for improving a bit the way NetBeans RCP projects are built.

In a previous blog post I've told you that I think a good way to distribute the sources of your NetBeans RCP project is to bundle the platform it requires to be built against (of course, if it's not the default NetBeans Platform).

I proposed the following directory layout in the distribution:

  • lib/nbm - where you place the referenced platform packaged in form of nbm files;
  • lib/nbm/NetBeans6.0RC1 - where you place the modules of the NetBeans Platform that you need to use;
  • lib/platform7-base - where you place some files from the NetBeans platform that can't be packaged into a nbm file;
  • src/ - your sources

Another directory would be used to keep the platform laid out so NetBeans can use it (this directory should not be distributed with sources):

  • lib/platform - where you place the referenced platform packaged in form of nbm files

Now, the following ant code will make it possible to generate the platform once and for all:

 <property name="platform.dir" value="lib/platform" />
 <property name="nbm.dir" value="lib/nbm" />

    <target name="generate-platform">
        <delete dir="${platform.dir}" failonerror="false" />
        <mkdir dir="${platform.dir}" />
        <copy todir="${platform.dir}/platform7">
            <fileset dir="lib/platform7-base" />
        <generatePlatform platformTargetFolder="${platform.dir}" >
            <fileset dir="${nbm.dir}"/>
            <fileset dir="${nbm.dir}/NetBeans6.0RC1"/>

Things can be further improved. If your project uses a custom platform, normally people should first configure NetBeans with the new platform in order to compile the files. But if you put the following code at the beginning of your ant script, you can have everything done for you automatically:

<project name="MyApplication" basedir="." default="build">
    <property name="platform.dir" value="lib/platform" />
    <property name="nbm.dir" value="lib/nbm" />
    <property file="nbproject/"/>
    <property file="nbproject/private/"/>
    <propertyfile file="${}" comment="">
        <entry key="nbplatform.${}.harness.dir" value="$${nbplatform.default.harness.dir}"/>
        <entry key="nbplatform.${}.label" value="${}"/>
        <entry key="nbplatform.${}.netbeans.dest.dir" value="${basedir}/${platform.dir}"/>
    <import file="nbproject/build-impl.xml"/>

Basically this code will just define the new platform in the IDE as you had manually configured it (probably the IDE must be restarted to be aware of the changes).

This means that you can distribute your project and just ask people to run ant generate-platform once, and then they can start working with it. As soon as I understand how to customize the ant initialization tasks, it will be possible to work by just opening the project with the IDE, as a plain J2SE project. More information in the OpenBlueSky documentation. You can download the sources and a preliminary binary of these ant tasks in OpenBlueSky.

BTW, what is OpenBlueSky? As I anticipated a few days ago, it's a collection of tools and components that I've factored out of blueMarine, for use in other applications. There are different things inside, from simple enhancements to RCP APIs, up to something more sophisticated as this CoverFlowView (here shining in blueMarine):

that can be just used as easily as a ListView (just set up a Lookup, an ExplorerManager and you've done). I'll post more details on this soon.

More in general, OpenBlueSky will provide some ad-hoc integration of cool stuff from SwingLabs so it will be easy to build a Filthy NetBeans Rich Client Application!

Stay tuned.

Technorati Tags: ,

Related Topics >>