-2

我正在使用maven-bundle-plugin并尝试捆绑 Google 地图依赖项。

        <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>

当我检查 JAR (Manifest.MF) 时,我可以看到com.google.maps.modelinExport-Package但看不到Import-Package. 我怎样才能得到它Import-Package呢?

这个问题链接到以前未解决的问题How to import a class from thirdparty jar file in an OSGi component

4

2 回答 2

0

如果您将 jar 嵌入到包中并希望访问其类,请使用 Include-Resource 指令,它有一个展开 JAR 资源的选项(请参阅@选项)

于 2015-10-19T18:34:30.677 回答
0

好吧,这里的 Import-Package 中不应该有任何东西,因为您不是在导入谷歌地图类,而是在嵌入它们。您将 google jar 打包到您自己的包中,并且 Import-Package 仅在您想使用从另一个包中导出的那些类时适用。

至于另一个问题,我不完全确定(我根本不使用 maven bundle 插件),但“exportcontents *”似乎很可疑,导出太多会导致微妙的问题。

我会说首先不导出任何内容并根据需要添加包。

于 2015-07-20T18:53:06.847 回答