2012-03-30 27 views
4

我使用這個簡單的pom.xml用來生成一個OSGi束的maven-bundle-pluginClasspath的空當添加<輸出目錄>到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.

這是一個錯誤?

+1

你可以嘗試調用MVN與'-X'選項,應該給你更多的調試輸出來幫助跟蹤下來。 – 2012-03-30 13:06:21

+0

您是否找到了此解決方案 – GPrathap 2015-11-05 05:26:09

+0

@GPrathap,不幸的是,這是很久以前的事了,我不記得我們最終做了什麼。 – 2015-11-05 11:53:31

回答

0

這是胡亂猜測,但嘗試要麼D:/TestD:\\Test

+0

這沒有幫助。此外,當我使用''以相同的方式工作。 – 2012-03-30 13:09:17

+0

基於[文檔](http://svn.apache.org/repos/asf/felix/releases/maven-bundle-plugin-2.3.7/doc/site/bundle-mojo.html#outputDirectory),它似乎'outputDirectory'觀察'$ {project.build.outputDirectory}'給出了什麼。我嘗試了一下你的示例配置;它也不適用於我。但是,當我將'$ {project.build.outputDirectory}'改成絕對路徑時,它工作正常。我的猜測是你不能獨立使用這兩種配置,或者插件還不支持這種功能。 – nobeh 2012-03-30 13:26:39

+0

路徑應該在/ D:/ Test /中用前導'/'來指定,但我不認爲這是錯誤的原因。 – earcam 2012-04-02 08:34:49

1

首先,我會建議檢查你的包配置,此外我絕不會使用像d特別依賴於平臺的路徑絕對路徑:\等等。另一方面Maven中默認是將創建的輸出目標文件夾。基於文檔,必須有更多的配置。

+0

絕對路徑當然只用於測試。 – 2012-03-30 15:44:13

+0

當然對於測試;-) – khmarbaise 2012-03-30 16:13:11

2

outputDirectory是在編譯的類已被寫入太 - 關於空classpath中「點」的錯誤是由於給行家束-插件的空目錄。

束插件MANIFEST.MF寫入到輸出目錄的位置,這也是在那裏它希望找到的任何其它元數據(例如SCR插件的輸出)爲束。

您使用的是編譯器插件嗎?如果不是,它看起來像bundle插件中的一個錯誤,它在調用編譯器時不尊重outputDirectory(但在其他地方遵守它)。

正如@nobeh指出的那樣,如果${project.build.outputDirectory}outputDirectory指向相同的位置,您應該沒問題。

+0

我不認爲這裏有一個錯誤 - 'maven-bundle-plugin'的文檔在這裏簡直是誤導。 – 2012-04-02 08:48:46

+0

如果您使用maven-bundle-plugin來執行編譯(即不是明確使用maven-compiler-plugin),那麼這是一個錯誤。否則,同意文件可以做得清楚一些。 – earcam 2012-04-02 09:03:21

相關問題