If you develop NetBeans modules you probably also wondered how to add a pre-packaged .nbm file as dependency to your module or how to use modules in multiple suites.
After some search I found that there is currently no official supported way for doing this. The reason is the bidirectional dependency between the suite and each module in the suite. This makes it hard to reuse modules across suites but it is still possible. In this entry I will describe different techniques/hacks to workaround this issue. (Note: technique, hack and workaround in the same sentence ;) )
In general, you can add a dependency to a module when the module you like to depend on is in:
a) your suite
b) the target NetBeans platform (default target platform is the installed IDE)
As mentioned above a) works only for one suite -> only b) is left
option 1. Assemble your own target platform:
point and click
- Either make a copy of NetBeans, or if there's a lot of stuff you don't want, create an empty suite. Then build it and create a zip distribution and unpack that
- Launch the result
- In Tools | Plugins, install the module(s) you want globally (check the "Force install into shared directories" checkbox)
- Shut it down
- In your real IDE, use Tools | NetBeans Platforms to point at the copy of the platform that now has the module you want in it
- Set your suite to build against that. It should pick up the module you installed and all classes in it's public packages
or put it in a build script
option 2. Install the module into your IDE:
point and click
- enable "Force install into shared directories" in Tools | Plugins | Settings
- install your module(s)
- restart NetBeans
- your module is now in the extra cluster and part of your IDE
or declarative
edit Info/index.xml inside your .nbm file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//NetBeans//DTD Autoupdate Module Info 2.5//EN" "http://www.netbeans.org/dtds/autoupdate-info-2_5.dtd">
<module codenamebase="org.yourorghere.module4" distribution="" downloadsize="0" global="true" homepage="" license="AD9FBBC9" moduleauthor="Michael Bien" needsrestart="false" releasedate="2008/04/07" targetcluster="milkyway">
<manifest AutoUpdate-Show-In-Client="true" OpenIDE-Module="org.yourorghere.module4" OpenIDE-Module-Implementation-Version="080407" OpenIDE-Module-Java-Dependencies="Java > 1.5" OpenIDE-Module-Name="module4" OpenIDE-Module-Requires="org.openide.modules.ModuleFormat1" OpenIDE-Module-Specification-Version="1.1"/>
<license name="AD9FBBC9">[NO LICENSE SPECIFIED]
</license>
</module>
alternatively you can add the flags to module/nbproject/project.properties and rebuild/create NBM (if source available)
nbm.is.global=true
nbm.target.cluster=milkyway
Now when you install the module with Tools | Plugins, NetBeans will place the module directly into the installation folder in the new created "milkyway" cluster. With this trick you should be able to use the same library wrapper module in as many suites you want.
Thanks to all on the mailing lists for the help on that topic.
------
I am already looking forward to JSR 277 which will hopefully replace the current implementation of the NetBeans module system. (no there was nothing anounced but this would make defenetive sense)