我使用 Maven 和 Tycho 插件来构建我的 OSGi 包。
在我的一个包中,我通过 restfb-1.7.0.jar 库使用了 facebook API。
目前,它直接放置在类路径上(在 Eclipse 中)并嵌入到具有以下 build.properties 配置的有效 OSGi 包 jar 文件中:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
lib/restfb-1.7.0.jar
现在我想从 Maven 下载这个 restfb 库(例如作为依赖项)并嵌入到我的 OSGi 包 jar 中。 Maven/Tycho 有可能吗?如何?
最佳答案
您需要以下配置才能使用 Tycho 将 JAR 嵌入到 OSGi 插件中:
copy
maven-dependency-plugin
的目标<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-libraries</id>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<item>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>1.7.0</version>
</item>
</artifactItems>
<outputDirectory>lib</outputDirectory>
<stripVersion>true</stripVersion>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Bundle-ClassPath: ., lib/restfb.jar
bin.includes = META-INF/,\
.,\
lib/restfb.jar
关于maven - 如何使用 Tycho 在 OSGi 包中嵌入库 JAR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28542595/