HowToReuseModules

These instructions are outdated. For newer instructions see DevFaqHowToReuseModules.


How to reuse modules across different NetBeans applications

(by Michael Bien)

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.

Contents


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 try describe different techniques to workaround this issue.

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
  • Richard Michalsky: Just a note, empty NB application is probably meant here, empty suite has all the clusters and modules included by default. Then you also need to rename launchers (under bin dir) back to nb, they get renamed according to application name.
  • 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 and add global=true and targetcluster="milkyway"

<?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">[NOLICENSESPECIFIED]
    </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.

this HowTo was based on this blog entry


JesseGlick: probably simpler and easier is to make a suite containing all the modules you want to share across apps. Then use that to create a base platform (ant -f $suite/build.xml create-platform) for your other suites, following the instructions for "suite chaining" in harness/README.


Thank you Jesse, we should really add this as third option. My initial problem what i had was to put a dependency on a already existing .nbm (e.g. a lib wrapper module or a downloaded module from the plugin portal) and AFAIK you can't add pre-packaged modules to a suite (maybe I overlooked something).

JesseGlick: right, a prepackaged NBM needs to be unpacked into your target platform somehow. Simply unzipping it almost gets it right except that update_tracking/*.xml would be missing in that case (you could probably create it manually with a little experimentation). NB 6.0 has a new API for the Update Manager which may be helpful here.

FabrizioGiudici I'm adding another option, which again starts from .nbm files, but overcomes some limitations of suite chaining. It's definitely more complex than other solutions, but at the point it's the only viable option I've found for my needs: http://weblogs.java.net/blog/fabriziogiudici/archive/2007/11/netbeans_rcp_be.html

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo