Is it possible to add entries to the manifest.mf file of jars generated by netbeans?
to build an osgi bundle for instance.
I clicked over to the "Files" tab, double-clicked on "manifest. mf" in the "build" folder, and edited the file to include this.
The manifest is a special file that can contain information about the files packaged in a JAR file. By tailoring this "meta" information that the manifest contains, you enable the JAR file to serve a variety of purposes.
The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections.
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>
Interesting information might be here:
http://wiki.netbeans.org/FaqNoMainClass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With