我是OSGI和Maven的新手,想要弄清楚如何在Eclipse中创建maven-osgi项目。我已经按照教程,能够做一个maven项目,也是一个OSGI项目,但我不能做一个包含它们的项目。Eclipse - 如何制作Maven + OSGI项目?
据我所知,OSGI项目最重要的部分是manifest.mf。在我的OSGI项目中,我有:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Osgi
Bundle-SymbolicName: osgi
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: osgi.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
maven项目的最重要的部分是它的pom.xml。在我的Maven项目,我有这样的:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.videobet.test</groupId>
<artifactId>quick</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>quick</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
我们这两个我想先做一个Maven项目,然后编辑pom.xml的所以它会增加一个OSGI项目的依赖,使清单相结合。 MF。为此,我尝试添加如下内容:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
但是我没有成功。首先我得到了这样的错误:
Plugin execution not covered by lifecycle configuration: org.apache.felix:maven-bundle-plugin:2.4.0:manifest (execution: bundle-manifest, phase: process-classes)
即使我能解决这个即时通讯不知道如果这将工作。我还发现了像tycho这样的不同插件可以帮助完成任务,但我真的不想使用它们。我想保持尽可能标准的事情,并自己做事情,所以我最终会明白什么即时通讯:)
任何帮助,将不胜感激!
您需要将包装类型设置为“捆绑”。 Maven-bundle-plugin生成MANIFEST.MF并将其放入Jar中,无需再使用单独的插件来构建Jar。 –
对不起,不太明白,你能稍微贬低一点吗? :) – user1985273
取出整个''部分,它很容易maven-jar-plugin。更改'瓶子 '到'包 ' –