Is it possible to add entries to the manifest.mf file of jars generated by netbeans?
to build an osgi bundle for instance.
Note that you can create a manifest on-the-fly via an ant task and set properties dynamically.
First, you must update your Netbeans "project.properties" file found in the "nbproject" directory. Add the following line to the file:
manifest.file=manifest.mf
Next, create an ant task to create/update the manifest using the "build.xml" file. In this example, we will set the version number and date of the jar file.
<target name="-pre-init">
<property name="project.name" value="My Library" />
<property name="version.num" value="1.4.1" />
<tstamp>
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss z" />
</tstamp>
<!--
<exec outputproperty="svna.version" executable="svnversion">
<arg value="-c" />
<redirector>
<outputfilterchain>
<tokenfilter>
<replaceregex pattern="^[0-9]*:?" replace="" flags="g"/>
<replaceregex pattern="M" replace="" flags="g"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
-->
<manifest file="MANIFEST.MF">
<attribute name="Bundle-Name" value="${project.name}" />
<attribute name="Bundle-Version" value="${version.num}" />
<attribute name="Bundle-Date" value="${NOW}" />
<!--<attribute name="Bundle-Revision" value="${svna.version}" />-->
<attribute name="Implementation-Title" value="${project.name}" />
<attribute name="Implementation-Version" value="${version.num}" />
<attribute name="Implementation-URL" value="http://www.example.com" />
</manifest>
</target>
This will create a manifest file in your netbeans project directory and stuff it into your jar file. If you want to delete the autogenerated manifest file from your netbeans project directory, simply create another ant task (post jar of course):
<target name="-post-jar">
<delete file="MANIFEST.MF"/>
</target>