Netbeans 清单 [英] Netbeans manifest

查看:16
本文介绍了Netbeans 清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在netbeans生成的jar的manifest.mf文件中添加条目?

Is it possible to add entries to the manifest.mf file of jars generated by netbeans?

例如构建一个 osgi 包.

to build an osgi bundle for instance.

推荐答案

请注意,您可以通过 ant 任务即时创建清单并动态设置属性.

Note that you can create a manifest on-the-fly via an ant task and set properties dynamically.

首先,您必须更新位于nbproject"目录中的 Netbeansproject.properties"文件.将以下行添加到文件中:

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

接下来,创建一个 ant 任务以使用build.xml"文件创建/更新清单.在本例中,我们将设置 jar 文件的版本号和日期.

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>

这将在您的 netbeans 项目目录中创建一个清单文件并将其填充到您的 jar 文件中.如果您想从您的 netbeans 项目目录中删除自动生成的清单文件,只需创建另一个 ant 任务(当然是 post jar):

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> 

这篇关于Netbeans 清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆