2015-11-05 59 views
1

我開始創建一個OSGI包。所以它工作正常。但是當我把輸出目錄放在maven bundle插件的配置部分時,它不會添加任何編譯類。簡單地說,類路徑是空的。我也使用maven編譯器插件。他們互相沖突嗎?有什麼我配置錯誤的方式。這是我的pox.xml文件的構建部分。如何在maven bundle插件中提供輸出目錄

<build> 
    <plugins> 

     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
      <version>1.4.0</version> 
      <extensions>true</extensions> 
      <configuration> 
       <instructions> 
        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
        <Bundle-Name>${project.artifactId}</Bundle-Name> 
        <Export-Package> 
         demo.wso2.orderprocess.* 
        </Export-Package> 
       </instructions> 
       <outputDirectory>/home/wso2/product/wso2esb-4.9.0/repository/components/dropins</outputDirectory> 
      </configuration> 
     </plugin> 

    </plugins> 

+0

我還沒有試過。但這可能是一個插件http://stackoverflow.com/questions/19964391/output-directory-for-maven-bundle-plugin中的錯誤,也參考http://stackoverflow.com/questions/9943392/classpath- empty-when-adding-outputdirectory-to-pom –

+0

Yeap我看到了。應該有辦法做到這一點。不應該? – GPrathap

+0

可能是你可以檢查maven來源:) –

回答

2

您應該使用<buildDirectory>/home/wso2/product/wso2esb-4.9.0/repository/components/dropins</buildDirectory>而不是<outputDirectory>/home/wso2/product/wso2esb-4.9.0/repository/components/dropins</outputDirectory>。它爲我做了竅門,現在我可以提高OSGI捆綁包開發的速度!

參考: Maven Bundle Plugin documentation

+0

cool ..接受了答案 – GPrathap

1

這裏是我做過什麼來解決這個問題,它的工作!

保持您的項目包裝類型爲「jar」並向其中添加OSGI元數據。這可以通過將執行目標添加到maven-bundle-plugin並且從引用maven-jar-plugin來實現。現在,只需將outputDirectory路徑添加到maven-jar-plugin您想放置該jar的位置。

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <configuration> 
    <archive> 
     <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
    </archive> 
    </configuration> 
    <outputDirectory>/path/to/output/directory</outputDirectory> 
</plugin> 
<plugin> 
    <groupId>org.apache.felix</groupId> 
    <artifactId>maven-bundle-plugin</artifactId> 
    <executions> 
    <execution> 
     <id>bundle-manifest</id> 
     <phase>process-classes</phase> 
     <goals>  
     <goal>manifest</goal> 
     </goals> 
    </execution> 
    </executions> 
</plugin> 

現在,要構建項目,請運行以下命令。這將生成清單文件並將其打包成jar。

mvn org.apache.felix:maven-bundle-plugin:manifest install 

參考:

Apache Felix Documentation

相關問題