我使用這個簡單的pom.xml
用來生成一個OSGi束的maven-bundle-plugin
:Classpath的空當添加<輸出目錄>到POM
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.test.osgi</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
可正常工作(該項目包含一個單一的公共類,我有經驗證可以在包中導出)。現在,如果我添加以下<configuration>
到插件:
<configuration>
<outputDirectory>D:\Test</outputDirectory>
</configuration>
構建失敗,出現以下錯誤:
[INFO] --- maven-bundle-plugin:2.3.7:bundle (default-cli) @ test ---
[WARNING] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : Classpath is empty. Private-Package and Export-Package can only expand from the classpath when there is one
[WARNING] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : Instructions in Private-Package, or -testpackages that are never used: .*
Classpath:
[ERROR] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : The JAR is empty: dot
[ERROR] Error(s) found in bundle configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.891s
[INFO] Finished at: Fri Mar 30 14:49:46 CEST 2012
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:2.3.7:bundle (default-cli) on project test: Error(s) found in bundle configuration -> [Help 1]
爲什麼在classpath空? <outputDirectory>
與它有什麼關係?這是一個錯誤,還是我誤解了一些東西?
編輯 運行調試輸出顯示類路徑確實與<outputDirectory>
相同。默認情況下,這是主目錄target
,所以他會在那裏找到要包含在類中的類。如果我改變它,它將指向一個不包含要包含的類的目錄。令人困惑的是,在documentation for the plugin說<outputDirectory>
是:
The directory for the generated bundles.
這是一個錯誤?
你可以嘗試調用MVN與'-X'選項,應該給你更多的調試輸出來幫助跟蹤下來。 – 2012-03-30 13:06:21
您是否找到了此解決方案 – GPrathap 2015-11-05 05:26:09
@GPrathap,不幸的是,這是很久以前的事了,我不記得我們最終做了什麼。 – 2015-11-05 11:53:31