在maven中添加Embed-Dependency

时间:2013-04-09 05:37:42

标签: maven osgi pom.xml apache-felix maven-bundle-plugin

实际上,当我构建项目时,它会将bundle部署到正在运行的OSGI控制台。现在捆绑包处于已安装状态,并显示一个红色警报,指出无法找到commons-net bundle。

解决这个问题的一种方法是将bundle明确地安装到运行的osgi框架本身。

另一种方法可能是向maven添加Embeded-Dependency。但这种方法不起作用。 我在maven-build-plugin中将指令标签添加了Embeded-Dependency。它没有显示任何错误。

如果有任何建议,请告诉我。

1 个答案:

答案 0 :(得分:2)

Embeded-Dependency没有显示任何错误,因为您可以在指令中添加任何内容。如果键值对未知,它将被简单地插入到MANIFEST.MF中。尝试编写Embed-Dependency,它应该可以使它工作。

一个很好的例子可能如下(我们如何为自己创建hibernate包):

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <_exportcontents>
                !org.hibernate.validator.*,
                org.hibernate.*;-noimport:=true,
            </_exportcontents>
            <Import-Package>
                javax.persistence*;version="1.1.0",
                javax.naming*,
                javax.sql,
                javax.transaction*;version="1.1.0",
                javax.xml.stream.*,
                javax.xml.*,
                org.slf4j,
                org.w3c.dom,
                org.xml.sax*,
                antlr.*,
                org.jboss.logging.*,
                org.dom4j*,
                *;resolution:=optional
            </Import-Package>
            <Embed-Dependency>
                groupId=org.hibernate;artifactId=hibernate-core,
                groupId=org.hibernate;artifactId=hibernate-entitymanager,
                groupId=org.hibernate.common;artifactId=hibernate-commons-annotations
            </Embed-Dependency>
        </instructions>
    </configuration>
</plugin>