OSGi and Maven discover private package use

I am starting a project that writes an OSGi package and uses Maven as a layout management tool. I understand that for the OSGi package, you can choose which package you would like to save as private / public.

Here is the question:

  • If I am dependent on a package declaring the com.example package as an exported package and declaring com.example.internal as a private package, is there any way during the build to detect the use of com.example.internal (should the assembly fail)?

It would be great if this were discovered during the development of Eclipse, but I really doubt that this is possible.

+4
source share
2 answers

One option is to use the Eclipse Plugin Development Environment (PDE), a toolkit that supports OSGi. It will not allow you to compile files with internal packages, so it gives you a check on development time. Unlike the maven bundle plugin, it appears first, not the code first, which not everyone likes.

To integrate PDE with Maven, it is best to use the Maven Tycho plugin . This gives you a fully prepared OSGi compilation phase in Maven.

+4
source

I think you will find a lot of support for this in bnd (tools). In general, I find these culprits by observing the Import-Package statement, which is well visualized in bndtools. There is some support in bnd (tools) for generating warnings / errors when an import package does not have an import range that occurs when importing a private or nonexistent package.

+1
source

All Articles