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

时间:2008-12-17 16:39:04

标签: maven-2 osgi dependencies

我正在开发一个基于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>

和报价的捆绑清单:

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

然后引用服务的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>

最后引用服务的清单:

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"

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

3 个答案:

答案 0 :(得分:12)

答案很简单:我删除了已经定义的清单,并在bundle插件指令中使用了bnd条目。那很有效!

答案 1 :(得分:3)

Tycho旨在解决这些类型的问题。

答案 2 :(得分:1)

我写了一个名为auto-builder的工具:http://code.google.com/p/auto-builder。它内省了基于PDE的项目并生成了Ant构建文件;它支持依赖关系和所有爵士乐的传递闭包。

我发了一篇文章:http://empty-set.net/?p=9。我写这篇文章是因为我使用的Maven工具,当与PDE集成时,并不“只是工作。”基本上,我想在PDE中进行编码并且在基于Hudson的CI之间没有任何大惊小怪。

生成Ant文件很不错,因为它为您提供了声明性构建工具的所有好处,但它为您提供了对它正在做什么的程序描述。

我正在寻找更多基于PDE的项目来测试它。有几个RFC-0112 Bundle存储库,我有一些代码用于下载依赖项。如果有人感兴趣,那么我可以将依赖项下载与自动构建器集成。

相关问题