Ever wondered, apart from extending the NetBeans IDE, or some application based on NetBeans Platform. What else can be done with the module?
Brief Overview
Well, NetBeans IDE provides Module Development Support by providing 4 kinds of Project Templates;
- Module
- Module Suite
- Library Wrapper Module
- NetBeans Platform Application
I have some knowledge of the first two, so we will stick to them for the rest of this post. So, lets have a look at the simplistic module structure;
This is what you see when you expand the Project node in Files View. We will focus on platform.properties, project.xml. If you switch to the Project View, you would see the files with following names, visible under Important Files node.
NetBeans Platform Config
So, that’s basically the logical view of the file platform.properties. In the past, I have written some pretty useful tips and Tricks (contributed to NetBeans Community Docs) based on this file;
- Configure Clusters and Modules
- Managing NetBeans Platforms
Project Metadata
This is the logical view of the file project.xml. There’s one more useful tips and Tricks (contributed), that’s based on this file, which lets you add your module as friends to those modules, if you want your module to depend on the specification version of the same.
Playing Tricks..
I will be making use of NetBeans 6.7 IDE. Although, these tricks should work well with NetBeans 6.x IDE. So, lets answer the question I asked in the beginning.. Generally, when you create Module project, you get an option to either create it as Standalone Module or Add to Module Suite.
Standalone Module
When you choose this option, you also get an option to select NetBeans Platform of your choice, along with Manage.. button. If you want to know more about that, refer this contribution.
Suppose, I choose NetBeans 6.5 Build (added with name as 65 in Platform Manager) as Platform and move ahead. I would be able to use 6.7 IDE to create module, targeted for NetBeans 6.5 IDE. The module’s platform.properties looks like this;
nbplatform.active=65
This would enable the running IDE to achieve the desired result, as mentioned above. Now, running the module will ofcourse launch NetBeans 6.5 IDE as Target Instance to see how your module works. This process might be slow, as you’re running full-fledged 6.5 IDE.
If your module doesn’t depend on clusters other than platform (which is by default). Then, you can tweak the file as follows;
enabled.clusters=\
platform
nbplatform.active=65
These clusters are bare-minimum essentials, that are enabled by default when you create the NetBeans Platform Application project using 6.5/6.7 IDE. The property enabled.clusters helps to enable only those clusters which are necessary to run this module.
Now, run your module and it will look like you’re running a NetBeans Platform Application having a single user-defined module. Here’s how module’s project.xml looks like;
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>code.name.base.of.your.module</code-name-base>
<standalone/>
<module-dependencies>
<!-- Here are your module dependencies.. -->
</module-dependencies>
<public-packages/>
</data>
</configuration>
</project>
Note the bold-faced tag <standalone />, this tells the NetBeans IDE that your module is not part of any module suite. Its a standalone module, as you created.
Add to Module Suite
If you decide to go with this option, you would then browse the filesystem to find the appropriate Module Suite project and then, move ahead.
In case of Module Suite projects, the enabled.clusters property automatically occurs/disappears, when you check/uncheck the modules and/or clusters from its Project Properties Wizard.
Note that the module, that becomes part of the suite, would use only those clusters which the suite has enabled. Along with that, suite-private.properties file is added under /nbproject/private. Also, take a look at the module’s project.xml;
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>code.name.base.of.your.module</code-name-base>
<suite-component/>
<module-dependencies>
<!-- Here are your module dependencies.. -->
</module-dependencies>
<public-packages/>
</data>
</configuration>
</project>
Note the bold-faced tag <suite-component/>, this tells that NetBeans IDE that this module is part of a Module Suite project.
Tips to Remember
You may convert your standalone module to become part of suite, or vice-versa. Just add/remove suite-private.properties (Per Suite Locator) file and tweak your Module’s project.xml and Module Suite’s project.properties.
Also, note that some changes have taken place in NetBeans 6.7 IDE, you may find out more over the web. One more thing, NetBeans 6.5 IDE added suite.properties file under /nbproject and had same tag as <suite-component/>. I think NetBeans 6.0 and 6.1 might do the same. Please try it yourself and let me know.
Stay tuned..