Maven:OSGI、捆绑包和多模块项目

发布于 2024-07-10 16:08:03 字数 4314 浏览 8 评论 0原文

我目前正在开发一个基于 OSGi 的应用程序(使用 Equinox),尝试将我在 OSGi+Equinox 上找到的网络教程进行 mavenize。 在这个项目中,有一些捆绑包依赖于其他捆绑包(报价服务取决于报价)。 编译阶段确实成功,但打包阶段没有成功。 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"

有什么问题吗? 先感谢您 !

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

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>

and the quote's bundle manifest :

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

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 !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ぺ禁宫浮华殁 2024-07-17 16:08:04

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

我发布了一篇文章:http://empty-set.net/?p=9。 我写它是因为我使用的 Maven 工具在与 PDE 集成时并不能“正常工作”。 基本上,我想在 PDE 中进行编码,并拥有一个基于 Hudson 的 CI,中间没有任何麻烦。

生成 Ant 文件很好,因为它为您提供了声明式构建工具的所有好处,但它为您提供了其正在执行的操作的过程描述。

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

I wrote a tool called auto-builder: http://code.google.com/p/auto-builder. It introspects PDE-based projects and generates Ant build files; it supports transitive closure over dependencies and all that jazz.

I posted a write-up: http://empty-set.net/?p=9. I wrote it because the Maven tools I played with, when integrated with PDE, didn’t “just work.” Basically, I wanted to do coding in PDE and have a Hudson-based CI without any fuss in between.

Generating Ant files is nice because it gives you all the benefits of a declarative build tool, but it leaves you with a procedural description of what it is doing.

I am looking for more PDE-based projects to test it on. There are a couple RFC-0112 Bundle repositories around, and I have some code for downloading dependencies. If anyone is interested, then I could integrate dependencies download with auto-builder.

无声情话 2024-07-17 16:08:03

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

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

蓝咒 2024-07-17 16:08:03

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

Tycho is designed to handle these types of problems.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文