Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse error with osgi + maven + maven-pax-plugin

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

like image 286
Hilikus Avatar asked Jul 12 '12 18:07

Hilikus


2 Answers

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!

like image 143
Peter Cliff Avatar answered Sep 18 '22 23:09

Peter Cliff


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.

like image 28
Christian Schneider Avatar answered Sep 20 '22 23:09

Christian Schneider