如何在使用maven

编程入门 行业动态 更新时间:2024-10-26 18:25:26
如何在使用maven-bundle-plugin时形成.bnd文件?(How to form the .bnd files while using maven-bundle-plugin?)

我想构建osgi组件,并且我被告知要使用maven-bundle-plugin 。 我开始将它添加到我的pom.xml :

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>3.0.0</version> <extensions>true</extensions> <configuration> <obrRepository>NONE</obrRepository> <instructions> <_include>-bnd.bnd</_include> </instructions> </configuration> </plugin>

注意传递给<_include>标记的.bnd文件。 我听说有人说这些文件应该保持在最低限度,甚至是空的,然后应该观察需要进口/出口等等。这是我感到困惑的地方。 我有我的MANIFEST.MF文件,我知道要导入和导出的内容。 但是,我需要一些帮助才能使我的.bnd文件正常工作。 现在我正在尝试使用空的.bnd文件,我不确定它是否正常工作。

有没有人有这个插件的经验和我希望它的工作方式?

例如, 这是一个示例.bnd文件。 但是我不知道他是如何确定这些应该是进口/出口的。

截至目前,当我尝试测试.jar我得到了

no main manifest attribute, in bundle-1.0.0.jar

尽管.jar确实存在MANIFEST.MF这个错误。

更新:我想我可以分享我以前想过的MANIFEST.MF ,我想通过这个插件生成。

Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Just a Name Bundle-SymbolicName: just.a.name.broker;singleton:=true Bundle-Version: 1.0.0 Require-Bundle: org.apache.activemq, just.msg Bundle-Activator: just.a.broker.Activator Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: javax.naming, javax.xml, javax.xml.parsers, org.apache.log4j.xml, org.osgi.framework Bundle-ClassPath: . Export-Package: just.a.broker

所以为了有这样的清单,我的.bnd文件应该怎么样? 或者更好的是在插件中包含属性而不是传递.bnd文件?

I'd like to build osgi components and I have been told to use maven-bundle-plugin. I started off by adding this into my pom.xml:

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>3.0.0</version> <extensions>true</extensions> <configuration> <obrRepository>NONE</obrRepository> <instructions> <_include>-bnd.bnd</_include> </instructions> </configuration> </plugin>

Notice the .bnd file which is passed to <_include> tag. I've heard people saying that these files should be kept at minimum, or even empty, and then should be observed what imports/exports are needed, etc. This is where I get confused. I have my MANIFEST.MF file, in which I know what to import and export. However, I need a bit of help to make my .bnd files working. Right now I am trying with empty .bnd files and I am not sure if it is working as it should be.

Does anyone have any experience with this plugin and the way I want to make it work?

For instance, here is a sample .bnd file. However I don't know how he decided that these should imports/exports be there.

As of now, when I try to test the .jar I get

no main manifest attribute, in bundle-1.0.0.jar

error despite of the fact that there is indeed MANIFEST.MF in the .jar.

Update: I thought I could share the MANIFEST.MF that I had previously, which I want to generate via this plugin now.

Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Just a Name Bundle-SymbolicName: just.a.name.broker;singleton:=true Bundle-Version: 1.0.0 Require-Bundle: org.apache.activemq, just.msg Bundle-Activator: just.a.broker.Activator Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: javax.naming, javax.xml, javax.xml.parsers, org.apache.log4j.xml, org.osgi.framework Bundle-ClassPath: . Export-Package: just.a.broker

So in order to have such a manifest, how should my .bnd file look like? Or is it better to include the properties in the plugin rather than passing the .bnd file?

最满意答案

您的.bnd文件可能如下所示:

Bundle-Activator: just.a.broker.Activator Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.apache.activemq,\ just.msg Import-Package: *,\ javax.naming,\ javax.xml,\ javax.xml.parsers,\ org.apache.log4j.xml,\ org.osgi.framework Bundle-ClassPath: . Export-Package: just.a.broker

希望这可以帮助。

your .bnd file may be look like this:

Bundle-Activator: just.a.broker.Activator Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.apache.activemq,\ just.msg Import-Package: *,\ javax.naming,\ javax.xml,\ javax.xml.parsers,\ org.apache.log4j.xml,\ org.osgi.framework Bundle-ClassPath: . Export-Package: just.a.broker

hope this helps.

更多推荐

本文发布于:2023-07-26 02:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1269903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   maven

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!