Maven:OSGI,捆绑和多模块项目 [英] Maven : OSGI, bundles and multi-modules projects

查看:139
本文介绍了Maven:OSGI,捆绑和多模块项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发基于OSGi的应用程序(使用Equinox),方法是在OSGi + Equinox上找到一个Web教程。在这个项目中,根据其他捆绑包(报价服务取决于报价)。
编译阶段确实成功,但是package阶段没有。 Maven抱怨以下内容:

I'm currently developing an OSGi based application (using Equinox) by trying to mavenize a web tutorial I've found on OSGi+Equinox. In this project, there are bundles depending on other bundles (quote-service depends on quote). The compile phase does succeed, but the package phase does not. Maven complains the following :


[INFO] [bundle:bundle]
[ERROR] Error building bundle de.vogella.osgi:quote-service:bundle:0.0.1 : Unresolved references to [de.vogella.osgi.quote] by class(es) on the Bundle-Classpath[Jar:dot]: [de/vogella/osgi/quoteservice/Activator.class, de/vogella/osgi/quoteservice/QuoteService.class]
[ERROR] Error(s) found in bundle configuration

我明白了这个问题,但是看不出如何使其发挥作用。
这是报价的pom:

I do understand the problem, but do not see how to make it work. This is the quote's pom :

<project xmlns="http://maven.apache.org/POM/4.0.0" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                             http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
    <artifactId>osgi-first-app</artifactId>
    <groupId>de.vogella.osgi</groupId>
    <version>0.0.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>de.vogella.osgi</groupId>
<artifactId>quote</artifactId>
<packaging>bundle</packaging>
<name>Quote Bundle</name>
<version>0.0.1</version>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>1.4.3</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <_include>src/main/resources/META-INF/MANIFEST.MF</_include>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

和报价单的清单:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Quote Plug-in
Bundle-SymbolicName: de.vogella.osgi.quote
Bundle-Activator: de.vogella.osgi.quote.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: de.vogella.osgi.quote

然后quote-service的pom:

Then the quote-service's pom :

<project xmlns="http://maven.apache.org/POM/4.0.0" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                             http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
    <artifactId>osgi-first-app</artifactId>
    <groupId>de.vogella.osgi</groupId>
    <version>0.0.1</version>
</parent>

<dependencies>
    <dependency>
        <groupId>de.vogella.osgi</groupId>
        <artifactId>quote</artifactId>
        <version>0.0.1</version>
        <type>bundle</type>
    </dependency>
</dependencies>

<modelVersion>4.0.0</modelVersion>
<groupId>de.vogella.osgi</groupId>
<artifactId>quote-service</artifactId>
<packaging>bundle</packaging>
<name>Quote Service Bundle</name>
<version>0.0.1</version>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>1.4.3</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <_include>src/main/resources/META-INF/MANIFEST.MF</_include>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

最后是报价服务的清单:

And finally the quote-service's manifest :

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Quoteservice Plug-in
Bundle-SymbolicName: de.vogella.osgi.quoteservice
Bundle-Activator: de.vogella.osgi.quoteservice.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.osgi.framework;version="1.3.0", \
 de.vogella.osgi.quote;version="0.0.1"

有什么问题吗?谢谢你提前!

Is there something wrong ? Thank you in advance !

推荐答案

答案很简单:我删除了已经定义的清单,并在捆绑中使用了bnd条目插件说明。这个工作!

The answer is quite simple : I removed the already defined manifest, and used bnd entries in the bundle plugin instructions. That works !

这篇关于Maven:OSGI,捆绑和多模块项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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