[RSS]

What is an NBM?

An NBM file is a NetBeans module packaged for delivery via the web. The principal differences between it and a module jar are:

  • It is compressed
  • It can contain more than one JAR file - modules can package any libraries they use into their NBM
  • It contains metadata NetBeans will use to display information about it in the update center, such as the manifest contents, the license, etc.
  • NBMs are typically signed for security purposes

NBM files are just zip files with a special extension, which use the JDK's mechanism for signing jars. Unless you're doing something unusual, you will not need to worry about the contents of NBMs - just let the standard Ant task for NBM creation take care of it for you. For those interested in gory details, read on.

Structure of an NBM

Below is an example of the contents of one - this is from the hexedit_integration module in contrib, which packages up an external library as well:
Info/
The place for metadata
Info/info.xml
Metadata - this file is generated by the standard NBM build target, so if you use NetBeans support for creating modules, you should not need to do anything special to create it. This info is used by the IDE to figure out if a module the user is installing is newer, older, than an existing one, whether or not its dependencies can be satisfied, etc.
META-INF/
The standard place for JAR manifests
META-INF/MANIFEST.MF
The manifest - nothing of interest here, it is just generated because NBMs are created the same way that JARs are
netbeans/
Contents of the cluster to be unpacked to the NetBeans installation.
netbeans/config/Modules/
Contains the module XML file used at runtime to discover modules - you have a lot of files just like this in $NB_HOME/somecluster/Modules
netbeans/config/Modules/org-netbeans-modules-hexeditor.xml
More metadata, with module type, whether it is autoload, etc. Used at runtime, not by the installer.
netbeans/modules/ext/hexedit.jar
A library this module uses and includes
netbeans/modules/org-netbeans-modules-hexeditor.jar
The actual module jar

Runtime module XML metadata

The org-netbeans-modules-hexeditor.xml runtime metadata file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//NetBeans//DTD Module Status 1.0//EN"
                        "http://www.netbeans.org/dtds/module-status-1_0.dtd">
<module name="org.netbeans.modules.hexeditor">
    <param name="autoload">false</param>
    <param name="eager">false</param>
    <param name="enabled">true</param>
    <param name="jar">modules/org-netbeans-modules-hexeditor.jar</param>
    <param name="release">1</param>
    <param name="reloadable">false</param>
    <param name="specversion">1.0</param>
</module>

Module installation metadata - Info.xml

The Info/Info.xml file that NetBeans uses to figure out if it _can_ install a module, dependencies, etc. looks like this (it also contains the license that the user will agree to to install the module from the update center):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//NetBeans//DTD Autoupdate Module Info 2.3//EN" "http://www.netbeans.org/dtds/autoupdate-info-2_3.dtd">
<module codenamebase="org.netbeans.modules.hexeditor"
        homepage="http://contrib.netbeans.org/"
        distribution="http://www.netbeans.org/download/nbms/40/org-netbeans-modules-hexeditor.nbm"
        license="standard-nbm-license.txt"
        downloadsize="0"
        needsrestart="false"
        moduleauthor=""
        releasedate="2005/08/29"
>
  <manifest OpenIDE-Module="org.netbeans.modules.hexeditor/1"
            OpenIDE-Module-Display-Category="Infrastructure"
            OpenIDE-Module-Implementation-Version="050829"
            OpenIDE-Module-Long-Description="Sample module hexeditor providing HexEdit"
            OpenIDE-Module-Module-Dependencies="org.openide.filesystems > 6.2, org.openide.util > 6.2, org.openide.nodes > 6.2, org.openide.windows > 6.2, org.openide.loaders"
            OpenIDE-Module-Name="hexeditor"
            OpenIDE-Module-Requires="org.openide.modules.ModuleFormat1"
            OpenIDE-Module-Short-Description="Sample hexeditor module"
            OpenIDE-Module-Specification-Version="1.0"
  />
  <license name="standard-nbm-license.txt"><![CDATA[This module is part of NetBeans and is open-source.
You can see http://www.netbeans.org/license.html for details.

You may use the binary however you like. The source file license is:

                Sun Public License Notice

The contents of this file are subject to the Sun Public License
Version 1.0 (the "License"). You may not use this file except in
compliance with the License. A copy of the License is available at
http://www.sun.com/

The Original Code is NetBeans. The Initial Developer of the Original
Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
Microsystems, Inc. All Rights Reserved.
]]></license>
</module>