Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use POM first or MANIFEST first when developing OSGi application with Maven?

There are two main approaches when developing an OSGi application with Maven: POM-first and MANIFEST first.

I'm looking for an answer that is in a form of a table that shows pros and cons of each method.

To be more specific, I would also like to know how it relates to:

  • Maturity of toolset
  • Vendor independence
  • Development ease (which includes finding people who can do the development on the tooling)
  • Compatibility
  • Avoiding ClassNotFound
  • Avoiding manual work
like image 210
Archimedes Trajano Avatar asked Jul 07 '12 07:07

Archimedes Trajano


2 Answers

At present this is what I can come up with

POM-First Pros (using maven-bundle-plugin)

  • Leverages existing Maven skills, repositories and tooling.
  • Likely easier to find people who know how to manage pom.xml rather than MANIFEST.MF along with pom.xml
  • Most of the information in MANIFEST.MF can be obtained from the pom.xml itself.
  • Can work with other IDEs not just Eclipse based ones.
  • Less invasive, just add the single plugin and change the packaging type to "bundle"

POM-First Cons

  • ClassNotFoundException more likely to occur at runtime. However, this can be mitigated using pax-exam (although it is very complicated to set up).
  • Still need to understand how the MANIFEST is setup to make sure the instructions configuration element is set correctly.

MANIFEST-first Pros (using tycho-maven-plugin)

  • Seems to be the recommended approach, or at least talked about as the recommended approach, but I can't really see why it has significant benefit. (Hence why this question was asked).
  • Good for developing Eclipse plugins and integrates well with PDE
  • Provides tooling for testing thus allowing ClassNotFoundException to appear during JUnit testing rather than runtime.

MANIFEST-first Cons

  • Seems to only work well on Eclipse based IDEs. You don't have to use Eclipse, but without the PDE would you want to?
  • Violates DRY principles since I have to do put keep the names and versions from the POM and MANIFEST.MF in sync.
  • Need to name things in a specific fashion
  • You cannot mix, meaning existing Maven multi-project installations cannot just tack on OSGi support
  • A lot more configuration compared to maven-bundle-plugin is needed to get less warnings: http://wiki.eclipse.org/Tycho/Reference_Card#Examplary_parent_POM
  • Have to make test cases a separate project. It won't run when built in src/test/java.
  • Seems that it will only test classes that are exposed, in other words those in ".internal." is not testable.

If I were asked for a recommendation for an enterprise that is using Maven already and want to move to OSGi then it would be POM first

If I were asked for a recommendation for someone who is doing Eclipse plugin development, then it is Manifest first -- with tycho

like image 64
Archimedes Trajano Avatar answered Oct 01 '22 09:10

Archimedes Trajano


I think you should choose by use case. For server side OSGi projects I favour the pom first style. It nicely matches the maven builds and is much less error prone than Manifest first. In fact bnd which is behind the maven bundle plugin gets the Manifest right for most cases without any additional config. The trick is to use some naming rules. For example if you name internal package impl or internal the will not be exported. Using this style you can not use the Eclipse plugin perspective (at least without bndtools which I do not like) but I did not yet miss this perspective. I am a developer in the Apache Karaf, CXF and Camel projects where we use this style and it works great. Especially for CXF and Camel it is great that we can support OSGi and non OSGi deployments with the same build and tools.

For Eclipse RCP applications Manifest first is the way to go as you need the plugin perspective and the Eclipse IDE tools. If you want to combine that with maven then tycho is probably the way to go.

like image 36
Christian Schneider Avatar answered Oct 01 '22 10:10

Christian Schneider