Search code examples
javamavenosgimaven-bundle-plugin

How to identify the source of a package version in the Manifest generated by maven-bundle-plugin


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.


Solution

  • 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