使用osgi + maven + maven-pax-plugin的Eclipse错误

Hil*_*kus 5 eclipse osgi maven m2e

我正在尝试创建一个OSGi包并将其集成到eclipse中.我正在使用maven-pax-plugin来创建捆绑包.这些是我遵循的步骤

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

mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=org.sonatype.mcookbook -DartifactId=osgi-project -Dversion=1.0-SNAPSHOT
Run Code Online (Sandbox Code Playgroud)

然后创建一个包

mvn pax:create-bundle -Dpackage=org.sonatype.mcookbook -Dname=osgi-bundle -Dversion=1.0-SNAPSHOT
Run Code Online (Sandbox Code Playgroud)

然后尝试将maven项目导入eclipse(文件/导入/现有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
Run Code Online (Sandbox Code Playgroud)

当我选择描述中的一个错误时

No marketplace entries found to handle Execution default-compile, in org.sonatype.mcookbook/pom.xml in Eclipse.  Please see Help for more information.
Run Code Online (Sandbox Code Playgroud)

如果我忽略错误并导入项目无论如何这都是eclipse抱怨的

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

有没有人见过这个?任何想法如何解决它?我正在学习本教程但是添加了与eclipse的集成.但请注意,如果我使用maven构建它并且根本不使用eclipse,那么一切正常,问题出在eclipse/m2e

我正在使用Eclipse Indigo SR2和m2e 1.0.200

小智 6

我通过遵循生成的POM中的注释并将其移至<extensions>true</extensions>下面的maven-bundle-plugin来解决此问题:

  ...
  <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>
    ...
Run Code Online (Sandbox Code Playgroud)

然后更新项目(右键单击Project Explorer中的项目名称:Maven - > Update Project ...),等待构建完成,错误消失.

希望有所帮助!


Chr*_*der 3

新的 m2eclipse 版本要求使用 m2eclipse 插件支持影响构建的每个插件。所以maven-pax-plugin尚不支持。由于大多数 Maven 插件都会发生这种情况,所以我仍然使用旧的 m2eclipse 版本。不幸的是,旧版本 0.12 下载最近似乎已被删除。因此,您可能必须等到 maven-pax-plugin 支持为止。