If you need to patch a pre-existing module, you can place a jar file relative to the original. For example, to patch ide5/modules/org-openide-example.jar you make a jar in ide5/modules/patches/org-openide-example/mypatch.jar. The mypatch part of your JAR file patch can be named anything you like. The JAR file should only contain those classes you want to patch, plus the normal manifest file that's created when building any JAR file.
The patch must be in the same cluster as the original. #69794 So, you cannot necessarily create an NBM containing a patch, unless you can be sure it will be installed in the same cluster. (Which is possible in NB 6.0: #64873)
There are two examples, one for a third party module and the second for patching a NetBeans module.
Here is an example of a module build file that produces a patch jar:
<project name="com.nuance.tools.speechproject" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project com.nuance.tools.speechproject.</description>
<import file="nbproject/build-impl.xml"/>
<target name="build-init" depends="harness.build-init">
<!--
when this is fixed: http://www.netbeans.org/issues/show_bug.cgi?id=69794
use this line instead
<property name="webproject-patch-dir" value="${cluster}/modules/patches/org-netbeans-modules-web-project"/>
-->
<property name="webproject-patch-dir" value="${netbeans.dest.dir}/enterprise2/modules/patches/org-netbeans-modules-web-project"/>
<property name="webproject-patch" value="${webproject-patch-dir}/vbuilder-patch.jar"/>
</target>
<target name="compile" depends="projectized-common.compile">
<mkdir dir="build/patch"/>
<javac srcdir="patchsrc"
destdir="build/patch"
debug="${build.compiler.debug}"
debuglevel="${build.compiler.debuglevel}"
deprecation="${build.compiler.deprecation}"
optimize="${build.compiler.optimize}"
source="${javac.source}"
target="${javac.target}"
includeantruntime="false">
<classpath refid="cp"/>
</javac>
</target>
<target name="jar" depends="projectized-common.jar">
<mkdir dir="${webproject-patch-dir}"/>
<jar jarfile="${webproject-patch}"
compress="${build.package.compress}">
<fileset dir="build/patch"/>
</jar>
</target>
<target name="clean" depends="projectized-common.clean">
<delete file="${webproject-patch}"/>
</target>
</project>
This is an example of a module build file that patches a module that is part of the NetBeans release. Tested on NetBeans 5.5 and 6.0. To use it, customize the ${module-patch-dir} and ${module-patch} properties, put the source tree for the patch in ${patch-source-dir} . Note that the compile target is different for NB6.
<project name="openide/awt" default="netbeans" basedir=".">
<import file="../../nbbuild/templates/projectized.xml"/>
<target name="basic-init" depends="projectized-common.basic-init">
<!--
when this is fixed: http://www.netbeans.org/issues/show_bug.cgi?id=69794
use this property value instead
<property name="module-patch-dir"
value="${cluster}/modules/patches/org-openide-awt"/>
-->
<property name="module-patch-dir"
value="${netbeans.dest.dir}/platform6/modules/patches/org-openide-awt"/>
<property name="module-patch"
value="${module-patch-dir}/Nb55UndoRedo-patch.jar"/>
<property name="patch-source-dir"
value="patchsrc"/>
<property name="patch-build-dir"
value="build/patch"/>
</target>
<!-- NetBeans 6.0:
<target name="compile" depends="projectized-common.compile">
-->
<target name="compile" depends="projectized.compile">
<mkdir dir="${patch-build-dir}"/>
<javac srcdir="${patch-source-dir}"
destdir="${patch-build-dir}"
debug="${build.compiler.debug}"
debuglevel="${build.compiler.debuglevel}"
deprecation="${build.compiler.deprecation}"
optimize="${build.compiler.optimize}"
source="${javac.source}"
target="${javac.target}"
includeantruntime="false">
<classpath>
<path refid="cp"/>
<pathelement location="build/classes"/>
</classpath>
</javac>
</target>
<target name="jar" depends="projectized-common.jar">
<mkdir dir="${module-patch-dir}"/>
<jar destfile="${module-patch}"
basedir="${patch-build-dir}"
compress="${build.package.compress}"/>
</target>
<target name="clean" depends="projectized-common.clean">
<delete dir="${module-patch-dir}"/>
<delete dir="${patch-build-dir}"/>
</target>
</project>