Maven:OSGI,捆绑和多模块项目

Pat*_*h24 11 dependencies osgi maven-2

我正在开发一个基于OSGi的应用程序(使用Equinox),试图对我在OSGi + Equinox上发现的网络教程进行编组.在这个项目中,有些捆绑包取决于其他捆绑(报价服务取决于报价).编译阶段确实成功,但封装阶段没有.Maven抱怨如下:

[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:

<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>
Run Code Online (Sandbox Code Playgroud)

和报价的捆绑清单:

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
Run Code Online (Sandbox Code Playgroud)

然后引用服务的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>
Run Code Online (Sandbox Code Playgroud)

最后报价服务的清单:

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"
Run Code Online (Sandbox Code Playgroud)

有什么不对 ?先感谢您 !

Pat*_*h24 12

答案很简单:我删除了已定义的清单,并在bundle插件指令中使用了bnd条目.这样可行 !