2011-05-03 19 views
2

我正在處理OSGi知識的整體,並遇到一個問題,其中示例中的指令對於完全不熟悉Ant的用戶來說是不夠的。編輯一個OSGi示例的ant build.xml文件 - 不理解指令

我按照jEdit並將其拆分爲捆綁包的示例,如OSGi in Action的示例第6章中所述。第一步是編輯build.xml文件,特別是刪除jar任務並將其替換爲bnd定義。然後告訴我'添加說明,告訴bnd放置生成的包的位置。這是我感到困惑的地方,因爲我之前沒有和Ant一起工作過,並計劃在這個例子之外使用Maven。 我希望有人能解釋這個例子要求我做什麼。該文如下(第6章第209頁):

First, comment out the jar task: 

<!-- jar jarfile="jedit.jar"     
    manifest="org/gjt/sp/jedit/jedit.manifest" 
    compress="false"> 
... 
</jar --> 

The first line above shows where to put the JAR file, 
and the second lists fixed manifest entries. Next, 
add the bnd definition and target task: 

<taskdef resource="aQute/bnd/ant/taskdef.properties" 
    classpath="../../../lib/bnd-0.0.384.jar" /> 
<bnd classpath="${build.directory}"   
    files="jedit-mega.bnd" /> 

Here, you first give the location of the bnd JAR file to tell 
Ant where it can find the bnd task definition. Then you specify 
a bnd task to create your bundle JAR file, giving it the project 
class path and the file containing your bnd instructions....The 
first thing you must add is an instruction to tell bnd where to 
put the generated bundle: 

-output: jedit.jar 

The bnd task can also copy additional manifest headers into the final 
manifest, so let’s ask bnd to include the original jEdit manifest rather 
than duplicate its content in your new file: 

-include: org/gjt/sp/jedit/jedit.manifest 

基本上,我不知道該怎麼做的 - 輸出和-include。我的編輯至今如下:

jEdit build.xml screenshot

回答

2

在這裏,這似乎是你的BND任務的官方文檔:

http://www.aqute.biz/Bnd/Ant

輸出,包括似乎是任務的屬性

所以它可能是:

<bnd classpath="${build.directory}"   
    files="jedit-mega.bnd" 
    output = 'jedit.jar'/> 

而且在命令行選項頁似乎輸出執行以下操作:

改寫默認輸出 名包或目錄。如果 輸出是目錄,則名稱將從bnd文件名派生,名稱將爲 。

但包括沒有提及任何地方。

這也可能是,這些值是指爲BND-文件本身(似乎是合理的): http://www.aqute.biz/Bnd/Format

+0

哎呀 - 是的。你對bnd-File是正確的。我現在完全不同地閱讀本節。出於某種原因,我認爲bnd文件將是一個生成的輸出,而不是我必須構建自己的東西。 – Aurora 2011-05-03 16:58:17