6

I am trying to create an OSGi bundle and integrate it into eclipse. I am using the maven-pax-plugin to create the bundles. These are the steps I follow

I create an osgi project using pax

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

and then create a bundle

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

and then try to import the maven project into eclipse (file/import/existing maven project) the bundle project created in the second step always gives me this error

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

When I select one of the errors the description says

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

If i ignore the error and import the project anyway this is what eclipse complains about

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

Has anyone seen this? any ideas how to fix it? I am following this tutorial but adding integration with eclipse. Note however that if I build it with maven and don't use eclipse at all it all works fine, the problem is in eclipse/m2e

I am using Eclipse Indigo SR2 and m2e 1.0.200

Hilikus
  • 9,954
  • 14
  • 65
  • 118
  • 1
    Have a look at [this](http://stackoverflow.com/a/7392705/367285) answer for the _Plugin execution not covered by lifecycle_ eclipse error. – FrVaBe Jul 12 '12 at 19:22

2 Answers2

7

I get rid of this problem by following the comment in the generated POM and move the <extensions>true</extensions> down to the maven-bundle-plugin below giving:

  ...
  <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>
    ...

Then update the project (Right click on project name in Project Explorer: Maven -> Update Project...), wait for the build to complete and the error is gone.

Hope that helps!

3

The new m2eclipse versions require that every plugin that affects the build is supported using a m2eclipse plugin. So the maven-pax-plugin is not yet supported. As this basically happens with most maven plugins out there I still use the old m2eclipse version. Unfortunately the old version 0.12 download seems to have been removed recently. So probably you will have to wait till maven-pax-plugin is supported.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • Thank you Christian. Do you know what exactly does m2e need to support? IIUC all we need for a plugin is a phase to trigger its call so i don't undestand what does m2e need to support – Hilikus Jul 13 '12 at 13:49
  • 1
    I think the main problem is that m2e does an incremental build so it needs to know when to invoke the plugin and which files change after the run. I am not sure how it works in detail though. – Christian Schneider Jul 13 '12 at 15:32