2012-07-12 55 views
4

我想創建一個OSGi包並將其集成到eclipse中。我正在使用maven-pax-plugin來創建捆綁。這些都是我按照Eclipse錯誤與osgi + maven + maven-pax-plugin

的步驟我使用PAX

mvn org.ops4j:maven-pax-plugin:create-project -DgroupId=org.sonatype.mcookbook -DartifactId=osgi-project -Dversion=1.0-SNAPSHOT 

,然後創建一個包

mvn pax:create-bundle -Dpackage=org.sonatype.mcookbook -Dname=osgi-bundle -Dversion=1.0-SNAPSHOT 

,然後嘗試將Maven項目導入到Eclipse中創建一個OSGi項目(文件/導入/現有Maven項目)在第二個步驟中創建總是包項目給了我這個錯誤

maven-pax-plugin:1.5:compile (1 error) 
    Execution default-compile, in org.sonatype.mcookbook/pom.xml 
maven-pax-plugin:1.5:testCompile (1 error) 
    Execution default-testCompile, in org.sonatype.mcookbook/pom.xml 

當我選擇了錯誤的一個描述說

No marketplace entries found to handle Execution default-compile, in org.sonatype.mcookbook/pom.xml in Eclipse. Please see Help for more information. 

如果我忽略錯誤並導入項目反正這就是日食抱怨

Plugin execution not covered by lifecycle configuration: org.ops4j:maven-pax-plugin:1.5:compile (execution: default-compile, phase: compile) 

有沒有人見過這個?任何想法如何解決它? 我正在關注this tutorial,但增加了與eclipse的集成。然而,需要注意的是,如果我與Maven構建它,並在所有這一切工作正常不使用Eclipse,問題是在eclipse/M2E

我使用Eclipse靛藍SR2和M2E 1.0.200

+1

看看這個[this](http://stackoverflow.com/a/7392705/367285)答案爲_Plugin執行不包含lifecycle_ eclipse錯誤。 – FrVaBe 2012-07-12 19:22:13

回答

3

新m2eclipse版本要求使用m2eclipse插件支持影響構建的每個插件。所以maven-pax-plugin還沒有被支持。因爲這基本上發生在大多數Maven插件外面,我仍然使用舊的m2eclipse版本。 不幸的是舊版本0.12下載似乎最近已被刪除。所以可能你必須等到maven-pax-plugin支持。

+0

謝謝基督教徒。你知道m2e需要支持什麼嗎? IIUC我們所需要的所有插件都是觸發它的調用的階段,所以我不清楚m2e需要支持什麼 – Hilikus 2012-07-13 13:49:51

+1

我認爲主要問題是m2e執行增量構建,因此它需要知道何時調用插件以及運行後更改哪些文件。我不確定它是如何詳細工作的。 – 2012-07-13 15:32:43

6

我得到下面的產生POM註釋和移動<extensions>true</extensions>下到Maven的捆綁,插件下面給擺脫這個問題:

... 
    <plugins> 
    <plugin> 
     <groupId>org.ops4j</groupId> 
     <artifactId>maven-pax-plugin</artifactId> 
     <version>1.4</version> 
     <!-- 
     | enable improved OSGi compilation support for the bundle life-cycle. 
     | to switch back to the standard bundle life-cycle, move this setting 
     | down to the maven-bundle-plugin section 
     --> 
     <!-- WAS HERE --> 
    </plugin> 
    <plugin> 
     <groupId>org.apache.felix</groupId> 
     <artifactId>maven-bundle-plugin</artifactId> 
     <version>1.4.3</version> 
     <!-- 
     | the following instructions build a simple set of public/private 
     | classes into an OSGi bundle 
     --> 
     <extensions>true</extensions> <!-- MOVED HERE :-) --> 
     <configuration> 
    ... 

然後更新項目(右鍵點擊項目名稱在Project Explorer中:Maven - > Update Project ...),等待構建完成並且錯誤消失。

希望有幫助!

+0

正是我在找的東西。每天我都會遇到與Maven和Eclipse不同的問題: - / – 2013-05-14 09:37:47