【问题标题】:OSGi Manifest is emptyOSGi 清单为空
【发布时间】:2016-12-19 15:24:24
【问题描述】:

我正在尝试创建一个服务,然后将它放到 felix OSGi 容器中。我尝试使用maven-bundle-plugin 来做到这一点。安装mvn clean install 软件包后,我也在target/classes/META-INF/MANIFEST.INF 中获得填充文件,但在jar 清单中看起来像这样:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: szymon.nowak
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_77`

它应该是这样的:

Manifest-Version: 1.0
Bnd-LastModified: 1471013023955
Build-Jdk: 1.8.0_77
Built-By: szymon.nowak
Bundle-Activator: com.cognifide.activators.HelloWorldActivator
Bundle-ManifestVersion: 2
Bundle-Name: Hello World Bundle - service
Bundle-SymbolicName: OSGi Hello World Service
Bundle-Vendor: Szymon Nowak
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: com.cognifide.service.first;version="1.0.0"
Import-Package: com.cognifide.service.first,org.osgi.framework;version="
 [1.5,2)"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.5))"
Tool: Bnd-3.2.0.201605172007

事实上,felix 注册了该文件,但它们无法正常工作,因为没有设置 Export-package 或 Activator。这就是我在 pom 中的插件定义的样子:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <executions>
        <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>
                <goal>manifest</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <instructions>
            <Bundle-SymbolicName>OSGi Hello World Service</Bundle-SymbolicName>
            <Export-Package>com.cognifide.service.first</Export-Package>
            <Bundle-Activator>com.cognifide.activators.HelloWorldActivator</Bundle-Activator>
            <Bundle-Name>Hello World Bundle - service</Bundle-Name>
            <Bundle-Vendor>Szymon Nowak</Bundle-Vendor>
        </instructions>
    </configuration>
</plugin>

编辑。

我使用mvn clean install 构建我的项目。也许我应该使用该插件的某个阶段?

【问题讨论】:

    标签: java maven osgi bundle


    【解决方案1】:

    尝试删除执行部分。我认为您现在拥有的内容告诉 maven-bundle-plugin 仅创建 Manifest 而不是打包它。

    还要确保你有

    <packaging>bundle</packaging>
    

    【讨论】:

    • executionstarget/classes/META-INF 中生成一个好的Manifest。删除后,我的 jar 文件中仍然没有创建好的 Manifest
    猜你喜欢
    • 2014-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-16
    相关资源
    最近更新 更多