【问题标题】:Maven : OSGI, bundles and multi-modules projectsMaven:OSGI、包和多模块项目
【发布时间】:2010-09-27 08:56:25
【问题描述】:

我目前正在开发一个基于 OSGi 的应用程序(使用 Equinox),尝试将我在 OSGi+Equinox 上找到的网络教程进行 mavenize。在这个项目中,有一些依赖于其他包的包(quote-service 依赖于报价)。 编译阶段确实成功,但打包阶段没有。 Maven 抱怨以下内容:

[信息] [捆绑:捆绑] [错误] 构建捆绑包 de.vogella.osgi:quote-service:bundle:0.0.1 时出错:Bundle-Classpath [Jar:dot] 上的类未解决对 [de.vogella.osgi.quote] 的引用: [de/vogella/osgi/quoteservice/Activator.class,de/vogella/osgi/quoteservice/QuoteService.class] [错误] 在捆绑配置中发现错误

我确实理解这个问题,但不知道如何使它工作。 这是引用的 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"

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

【问题讨论】:

    标签: maven-2 osgi dependencies


    【解决方案1】:

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

    【讨论】:

    • 我相信这个问答有一天会对我非常有用,所以我投了赞成票。谢谢!
    【解决方案2】:

    Tycho 旨在处理这些类型的问题。

    【讨论】:

      【解决方案3】:

      我编写了一个名为 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 存储库,我有一些用于下载依赖项的代码。如果有人有兴趣,那么我可以将依赖项下载与自动生成器集成。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-09-18
        • 1970-01-01
        • 2011-04-07
        • 1970-01-01
        • 2019-05-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多