如何使用 Maven 结构化项目在 Eclipse 中调试 OSGi Bundle
我有一个 Maven 项目,该库也应该是一个 OSGi 捆绑包,其中包含 声明式服务。我添加了 OSGI-INF 文件夹,其中包含 service.xml src/java/resources 将被添加到 jar 中。但是:当我将项目作为 equinox 项目启动时,我想检查服务是否已加载,但出现错误,无法找到 OSGI-INF/service.xml。我猜 Eclipse 启动时不会将资源文件夹添加到类路径中。
顺便说一句:MANIFEST-MF 位于根文件夹中,并且 pom.xml 包含以下文本:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
有一个好主意如何告诉 Eclipse 在哪里可以找到元数据文件吗?如果相关的话我正在使用 m2eclipse。
提前致谢 汉内斯
I have a maven project which library should also be an OSGi bundle with an
declarative service. I added the OSGI-INF folder with the service.xml inside
src/java/resources which will be added to the jar. But: When I start the project as equinox project, where I want to check if the service is loaded, I get the error that the OSGI-INF/service.xml can't be found. I guess eclipse won't add the resources folder to the classpath when starting.
BTW: The MANIFEST-MF is in the root folder and the pom.xml contains the following text:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
Has anbody a good idea how to tell eclipse where to find the metadata files? I'm using m2eclipse if this is relevant.
Thanks in advance
Hannes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有同样的问题,但我手动调整了 POM.xml,以将生成 target/classes/META-INF/** 内容(MANIFEST.MF、属性文件、spring XML...)复制到项目根目录中文件夹(Eclipse PDE 期望的):(
当调用 mvn clean 时我也会清理一些东西)它并不是真正有效,但它可以工作。
Ps:您可能必须右键单击该项目并将其设为插件项目才能使其工作。
I've the same issues but I've manually tweaked my POM.xml for copying the generate target/classes/META-INF/** stuff (MANIFEST.MF, property files, spring XMLs, ...) into the project ROOT folder (which Eclipse PDE expects):
(I also clean up things when mvn clean is called) It is not really efficient but it works.
Ps: you may have to right-click on the project and make it a plug-in project in order for this to work.
问题是 Eclipse 需要根目录中的 OSGI-INF(以及 META-INF)文件夹。
我找到了有关如何解决该问题的链接。
https://www.nuxeo.com/blog/ working-with-osgi-and-maven-in-eclipse/
基本上他们将 OSGI-INF 和 META-INF 文件夹放入 src/main/resources
然后他们将 src/main/resources 文件夹设置为根目录OSGI 项目。这样 Eclipse 的根目录下就有这两个文件夹。
为了让源文件也可用,他们添加了 通过向 .project 文件添加条目将资源链接到 src/main/java
现在您只需将 .prject 和 .classpath 文件复制到 src/main/resources (您的新根目录)一切都应该正常。
在撰写本文时,我还没有自己对此进行测试,但会在不久的将来进行测试。
The Problem is that Eclipse needs that OSGI-INF (and also META-INF) Folder in root.
I have found a link on how to probably solve the problem.
https://www.nuxeo.com/blog/working-with-osgi-and-maven-in-eclipse/
Basically they put the OSGI-INF and META-INF Folders into src/main/resources
Then they set the src/main/resources Folder as root of the OSGI project. So that Eclipse has both Folders at root.
To have Soure Files also available they added a Linked Resources to src/main/java by adding an entry to the .project File
Now you just need to copy the .prject and .classpath Files into src/main/resources (your new root) and everything should be working.
By the time of this writing i didn't test this on my own but will do so in the near future.