Jun Qian (钱骏) 's Weblog

Wednesday Jul 11, 2007

Tip of the Day: NetBeans Platform and Inter-Suite Dependency

Q: You want to build a NetBeans-based application. You have decided that you want to divide your application-specific functionality into multiple module suites (S1, S2, ...). There will be inter-suite dependency like the following. How do you do this?

Suite Dependency Map

First, a few NetBeans terms if you are not familiar with them:

A Module Suite is a container project for related module projects. Module projects inside a suite can refer to one another as well as to a NetBeans Platform.

A NetBeans Platform is a NetBeans instance on your disk that you can build your application against.

A Cluster is a subdirectory of a NetBeans-based-application's binary installation. It has nothing to do with Module Suite. Every module in your NetBeans-based application falls into one cluster. If you take a look at the full installation of NetBeans 6.0, you will find clusters (under your NetBeans root directory) like apisupport1, enterprise4, ide8, java1, nb6.0, platform7, profiler2, ruby1, soa1 and visualweb1.

 

Here are the steps you need to do:

  • Start your NetBeans IDE (say, from C:/Program Files/NetBeans 6.0 M9/bin/)
  • Add a new NetBeans Platform in your NetBeans IDE using Tools->NetBeans Platform. Select another instance of NetBeans on your disk (for example, C:/opt/netbeans). Give the platform a name, say, "My Platform". You will be building your application on top of this platform and augment the platform itself.
NetBeans Platform Manager
  • Create your first module suite S1 and select "My Platform" to be its NetBeans Platform.
Create Suite S1 on "My Platform"
  • Create your module projects in S1
  • Edit S1's nbproject/platform.properties to include something like the following:
          cluster.dir.name=<YOUR_TARGET_CLUSTER_NAME>                 
          cluster.dir=<YOUR_NB_PLATFORM_DIR>/${cluster.dir.name}
 for example:
    cluster.dir.name=mycluster1
    cluster.dir=C:/opt/netbeans/${cluster.dir.name}
  • Build module suite S1.
  • (You should see the build artifacts of S1's modules appearing under ${cluster.dir}/modules/ now. )
  • Create your second module suite S2 and select "My Platform" to be its NetBeans Platform
  • Create your module projects in S2
  • Declare your inter-suite dependencies (S2 depends on S1)
  • Edit S2's nbproject/platform.properties to include something like the following:
          cluster.dir.name=<YOUR_TARGET_CLUSTER_NAME>
          cluster.dir=<YOUR_NB_PLATFORM_DIR>/${cluster.dir.name}
  • Build module suite S2
  • (You should see the build artifacts of S2's modules appearing under ${cluster.dir}/modules/ now. )
  • Add your extra cluster(s) into your platform's etc/netbeans.conf:
          netbeans_extraclusters="/absolute/path/to/mycluster1:/absolute/path/to/mycluster2"

(Alternatively, if your extra clusters sit in parallel with NetBeans' clusters, you could edit your platform's etc/netbeans.clusters to include your extra clusters' names.)

  • Start your NetBeans-based application (C:/opt/netbeans/bin)

 

The following graph shows a summary of what we have done. Note that both S1's platform and S2's platform point to the same instance of NetBeans on your disk.

Suite Build Order
Always take a note of the direction of inter-suite dependency. Higher-level suite can depend on lower-level suite but not the other way around. If after building all the suites, you accidentally introduce a dependency from lower level to upper level (say, from S1 to S2), it might seem to work for you temporarily (because you have already had S2 built), but the compilation will fail the next time you build the whole application.

 
Reference:

  • http://www.java-tips.org/other-api-tips/netbeans/what-is-the-difference-between-a-suite-and-a-cl.html 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed

Archives
Links
Referrers