osgi+maven+maven pax插件出现Eclipse错误



我正在尝试创建一个OSGi捆绑包并将其集成到eclipse中。我正在使用maven-pax插件来创建捆绑包。以下是我遵循的步骤

我使用pax 创建了一个osgi项目

mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=org.sonatype.mcookbook -DartifactId=osgi-project -Dversion=1.0-SNAPSHOT

然后创建一个捆绑

mvn pax:create-bundle -Dpackage=org.sonatype.mcookbook -Dname=osgi-bundle -Dversion=1.0-SNAPSHOT

然后尝试将maven项目导入eclipse(文件/import/existing maven项目)第二步中创建的bundle项目总是给我这个错误

maven-pax-plugin:1.5:compile (1 error)
   Execution default-compile, in org.sonatype.mcookbook/pom.xml
maven-pax-plugin:1.5:testCompile (1 error)
   Execution default-testCompile, in org.sonatype.mcookbook/pom.xml

当我选择其中一个错误时,描述显示

No marketplace entries found to handle Execution default-compile, in org.sonatype.mcookbook/pom.xml in Eclipse.  Please see Help for more information.

如果我忽略错误并导入项目,这就是eclipse对的抱怨

Plugin execution not covered by lifecycle configuration: org.ops4j:maven-pax-plugin:1.5:compile (execution: default-compile, phase: compile)

有人看到这个吗?有什么办法解决的吗?我遵循本教程,但添加了与eclipse的集成。然而,请注意,如果我使用maven构建它,并且根本不使用eclipse,那么一切都很好,问题就出在eclipse/m2e 中

我使用的是Eclipse Indigo SR2和m2e 1.0.200

我通过遵循生成的POM中的注释来解决这个问题,并将<extensions>true</extensions>向下移动到下面的maven bundle插件中,给出:

  ...
  <plugins>
    <plugin>
      <groupId>org.ops4j</groupId>
      <artifactId>maven-pax-plugin</artifactId>
      <version>1.4</version>
      <!--
         | enable improved OSGi compilation support for the bundle life-cycle.
         | to switch back to the standard bundle life-cycle, move this setting
         | down to the maven-bundle-plugin section
        -->
      <!-- WAS HERE -->
    </plugin>
    <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <version>1.4.3</version>
      <!--
       | the following instructions build a simple set of public/private
       | classes into an OSGi bundle
      -->
      <extensions>true</extensions> <!-- MOVED HERE :-) -->
      <configuration>
    ...

然后更新项目(右键单击项目浏览器中的项目名称:Maven->更新项目…),等待构建完成,错误就消失了。

希望能有所帮助!

新的m2eclipse版本要求使用m2eclipse插件支持每个影响构建的插件。因此,maven-pax插件还不受支持。由于大多数maven插件基本上都是这样,所以我仍然使用旧的m2eclipse版本。不幸的是,旧版本0.12的下载最近似乎被删除了。所以你可能要等到maven-pax插件得到支持。

最新更新