1

I'm creating an OSGI bundle from a Maven module with the use of maven-bundle-plugin.

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <configuration>
        <instructions>
            <Import-Package>
                *
            </Import-Package>
            <Export-Package>
                my.bundle.packages
            </Export-Package>
        </instructions>
    </configuration>
</plugin>

Unfortunately, there seems to be a dependency which exposes javax.annotation. Because of this, the generated Manifest contains Import-Package: javax.annotation;version="[3.2,4)"

How can I find out which dependency exports this package? By using mvn dependency:list I've been able to exclude a few dependencies (com.google.code.findbugs:annotations and com.google.code.findbugs:jsr305), but still the version range remains. I've been looking in the Manifest-files of the direct dependencies, but have not found any other jar exporting javax.annotation.

Note: I could add a dependency to javax.annotation:com.springsource.javax.annotation and the Manifest would correctly import javax.annotation version 1.0.0, but this shouldn't be necessary and I personally would find it cleaner to exclude the unknown dependency.

TomVW
  • 1,510
  • 13
  • 26

1 Answers1

0

How can I find out which dependency exports this package?

If you have *nix console and bndcommand line tool installed you could try:

mvn dependency:build-classpath | grep jar | tr ':' ' ' | xargs bnd find -e 'javax.annotation'

There is probably a better way to do this but it's a staring point

Milen Dyankov
  • 2,972
  • 14
  • 25
  • This has been helpful in a way. The dependencies which I identified before are the only ones that expose that package. However the Manifest still specifies the incorrect version. – TomVW Dec 12 '16 at 16:52
  • Turns out I can't read the Manifest correctly. This command helped me find the problematic dependencies and does list the jars that expose the package – TomVW Dec 13 '16 at 11:05