-2

I'm using the maven-bundle-plugin and trying to bundle Google maps dependency.

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-ClassPath>*;scope=compile|runtime</Bundle-ClassPath>

                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Embed-Directory>OSGI-INF/lib</Embed-Directory>
                    <Import-Package>
                        *
                    </Import-Package>
                    <_exportcontents>
                                *
                    </_exportcontents>
                </instructions>
            </configuration>
        </plugin>

When I inspect the JAR (Manifest.MF) I can see com.google.maps.model in Export-Package but not in Import-Package. How can I get it in the Import-Package as well?

This question is linked to a previously unresolved question How to import a class from third party jar file in an OSGi component

Community
  • 1
  • 1
Anthony
  • 33,838
  • 42
  • 169
  • 278

2 Answers2

0

Well, there shouldn't be anything in the Import-Package here, as you're not importing the google maps classes, you are embedding them. You're packing the google jar inside your own bundle, and Import-Package applies only when you want to use those classes exported from another bundle.

As of the other question, I'm not entirely sure (I don't use the maven bundle plugin at all) but the 'exportcontents *' seems suspect, exporting too much can lead to subtle problems.

I'd say start by exporting nothing and add packages as needed.

Frank Lee
  • 2,728
  • 19
  • 30
0

If you are embedding the jar in your bundle and want to access its classes, use the Include-Resource instruction, it has an option to unroll a JAR resource (see @ option)

Pushkin
  • 524
  • 4
  • 16