Including External NetBeans Modules Via Add Project/Add Cluster
By Geertjan on Aug 22, 2011
When working with Ant-based NetBeans Platform application projects, you can include external NetBeans modules in your application, and set dependencies on them, in one of two ways.
I've never completely understood the difference between the two, so here's my understanding of it now, i.e., the difference between "Add Project" and "Add Cluster" in the "Libraries" tab of the Project Properties dialog of NetBeans Platform application projects:
- Add Project. Use this approach when you have access to the source of the NetBeans module that you want to include. I.e., somewhere on disk, you will have the sources of another NetBeans Platform application project or a NetBeans module project.
- Add Cluster. Use this approach when you do not have access to the sources of the application or module you'd like to include. Instead, you have the application binary somewhere, such as the VisualVM application in the JDK. In that case, use "Add Cluster" and the modules in the selected cluster will be accessible to the modules in your application and will be packaged with your application.
In the case of "Add Cluster", you might also want to be able to use code completion and look into the sources of the modules you include. That's why you can explicitly include sources and javadoc when you include a cluster into the application. When you use "Add Project", you have the sources available already, which means that you also have access to the related javadoc, defined within those sources.
If you use "Add Project", the project in question should be built, otherwise your application's build will fail, just as if you had used "Add Cluster", which also uses built modules.
None of this should be confused with transitive builds. I.e., if you have the sources of VisualVM available, and you use "Add Project" to include a module from VisualVM, you will not automatically rebuild the VisualVM module when you rebuild your application. That is not supported. If you really want transitive builds, use Maven instead.
A simple way (I am a simple person) to understand the difference between the two approaches described here is to see "Add Project" as "Reuse External Source" and "Add Cluster" as "Reuse External Binaries".