【问题标题】:Eclipse error with osgi + maven + maven-pax-pluginosgi + maven + maven-pax-plugin 的 Eclipse 错误
【发布时间】:2012-07-12 13:22:16
【问题描述】:

我正在尝试创建一个 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

然后创建一个包

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

然后尝试将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

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

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)

有人看过吗?任何想法如何解决它? 我正在关注this tutorial,但添加了与 Eclipse 的集成。但是请注意,如果我使用 maven 构建它并且根本不使用 eclipse,那么一切正常,问题出在 eclipse/m2e

我正在使用 Eclipse Indigo SR2 和 m2e 1.0.200

【问题讨论】:

  • 查看this生命周期未涵盖的插件执行 eclipse 错误的回答。

标签: eclipse maven osgi m2e


【解决方案1】:

我通过遵循生成的 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>
    ...

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

希望有帮助!

【讨论】:

  • 正是我想要的。每天我对 Maven 和 Eclipse 都有不同的问题:-/
【解决方案2】:

新的 m2eclipse 版本要求使用 m2eclipse 插件支持每个影响构建的插件。所以 maven-pax-plugin 还不支持。因为这基本上发生在大多数 maven 插件上,所以我仍然使用旧的 m2eclipse 版本。 不幸的是,最近似乎已删除旧版本 0.12 下载。所以可能你必须等到支持 maven-pax-plugin。

【讨论】:

  • 谢谢克里斯蒂安。你知道m2e到底需要支持什么吗? IIUC 一个插件我们只需要一个阶段来触发它的调用,所以我不明白 m2e 需要支持什么
  • 我认为主要问题是 m2e 进行增量构建,因此它需要知道何时调用插件以及运行后哪些文件发生更改。不过我不确定它是如何工作的。
猜你喜欢
  • 2013-02-10
  • 1970-01-01
  • 1970-01-01
  • 2011-05-21
  • 2012-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-20
相关资源
最近更新 更多