2008-12-17 17 views
11

我目前正在開發一個基於OSGi的應用程序(使用Equinox),試圖將我在OSGi + Equinox上找到的Web教程變爲新鮮事。在這個項目中,有捆綁取決於其他包(報價服務取決於報價)。 編譯階段確實成功,但程序包階段不成功。 Maven抱怨以下幾點:Maven:OSGI,捆綁軟件和多模塊項目

 
[INFO] [bundle:bundle] 
[ERROR] Error building bundle de.vogella.osgi:quote-service:bundle:0.0.1 : Unresolved references to [de.vogella.osgi.quote] by class(es) on the Bundle-Classpath[Jar:dot]: [de/vogella/osgi/quoteservice/Activator.class, de/vogella/osgi/quoteservice/QuoteService.class] 
[ERROR] Error(s) found in bundle configuration 

我明白這個問題,但看不出如何使它工作。 這是引用的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/maven-v4_0_0.xsd"> 

<parent> 
    <artifactId>osgi-first-app</artifactId> 
    <groupId>de.vogella.osgi</groupId> 
    <version>0.0.1</version> 
</parent> 

<modelVersion>4.0.0</modelVersion> 
<groupId>de.vogella.osgi</groupId> 
<artifactId>quote</artifactId> 
<packaging>bundle</packaging> 
<name>Quote Bundle</name> 
<version>0.0.1</version> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
      <version>1.4.3</version> 
      <extensions>true</extensions> 
      <configuration> 
       <instructions> 
        <_include>src/main/resources/META-INF/MANIFEST.MF</_include> 
       </instructions> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 
</project> 

和報價單的捆綁包清單:

Manifest-Version: 1.0 
Bundle-ManifestVersion: 2 
Bundle-Name: Quote Plug-in 
Bundle-SymbolicName: de.vogella.osgi.quote 
Bundle-Activator: de.vogella.osgi.quote.Activator 
Bundle-ActivationPolicy: lazy 
Bundle-RequiredExecutionEnvironment: J2SE-1.5 
Import-Package: org.osgi.framework;version="1.3.0" 
Export-Package: de.vogella.osgi.quote 

然後報價服務的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/maven-v4_0_0.xsd"> 

<parent> 
    <artifactId>osgi-first-app</artifactId> 
    <groupId>de.vogella.osgi</groupId> 
    <version>0.0.1</version> 
</parent> 

<dependencies> 
    <dependency> 
     <groupId>de.vogella.osgi</groupId> 
     <artifactId>quote</artifactId> 
     <version>0.0.1</version> 
     <type>bundle</type> 
    </dependency> 
</dependencies> 

<modelVersion>4.0.0</modelVersion> 
<groupId>de.vogella.osgi</groupId> 
<artifactId>quote-service</artifactId> 
<packaging>bundle</packaging> 
<name>Quote Service Bundle</name> 
<version>0.0.1</version> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
      <version>1.4.3</version> 
      <extensions>true</extensions> 
      <configuration> 
       <instructions> 
        <_include>src/main/resources/META-INF/MANIFEST.MF</_include> 
       </instructions> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 
</project> 

最後報價服務的清單:

Manifest-Version: 1.0 
Bundle-ManifestVersion: 2 
Bundle-Name: Quoteservice Plug-in 
Bundle-SymbolicName: de.vogella.osgi.quoteservice 
Bundle-Activator: de.vogella.osgi.quoteservice.Activator 
Bundle-ActivationPolicy: lazy 
Bundle-RequiredExecutionEnvironment: J2SE-1.5 
Import-Package: org.osgi.framework;version="1.3.0", \ 
de.vogella.osgi.quote;version="0.0.1" 

有什麼問題嗎?先謝謝你 !

回答

12

答案很簡單:我刪除了已定義的清單,並在捆綁插件說明中使用了bnd條目。這樣可行 !

+0

我敢肯定,這個問答對我來說有一天會非常有用,所以我投了票。謝謝! – 2008-12-23 08:18:57

3

Tycho旨在處理這些類型的問題。

1

我寫了一個名爲auto-builder的工具:http://code.google.com/p/auto-builder。它反省了基於PDE的項目並生成Ant構建文件;它支持依賴關係和所有爵士樂的傳遞閉包。

我發表了一篇文章:http://empty-set.net/?p=9。我寫這篇文章是因爲我與之搭配使用的Maven工具與PDE集成後,並不「正常工作」。基本上,我想在PDE中編寫代碼,並且在哈德森編碼中使用CI,而不用擔心。

生成Ant文件是很好的,因爲它爲您提供了聲明性構建工具的所有優點,但它爲您提供了它正在執行的過程描述。

我在尋找更多基於PDE的項目來測試它。有一些RFC-0112 Bundle存儲庫,我有一些用於下載依賴關係的代碼。如果任何人有興趣,那麼我可以將自動構建器的依賴關係下載。