我發現了一種使用Maven以相對OSGi標準方式執行此操作的方法。它使用maven-dependency-plugin來創建只包含運行時作用域所需的依賴關係的存儲庫。
然後執行maven-bundle-plugin:index目標來創建repository.xml文件。
在這個目標中你有一個有效的obr倉庫,maven-assembly-plugin可以用來根據需要打包它。
以下pom.xml代碼段將執行所需的操作。
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-runtime-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<copyPom>true</copyPom>
<useRepositoryLayout>true</useRepositoryLayout>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>index</id>
<goals>
<goal>index</goal>
</goals>
<phase>verify</phase>
<configuration>
<mavenRepository>${project.build.directory}/dependency</mavenRepository>
</configuration>
</execution>
</executions>
</plugin>
至於Karaf,這與它的傳遞依賴沿束可以在不使用Karaf的feature.xml的使用以下命令進行安裝:
features:install obr
obr:addUrl [location of the OBR repository, can be file:///....]
obr:deploy [symbolicname-of-bundle]
start [symbolicname-of-bundle]
瞧。
請注意,這隻會加載您指定的包所引用的包,因此如果您使用的是類似Blueprint的東西,理論上它不應該知道其他包,那麼您必須顯式部署他們或創建一個超級捆綁包,將包含你有捆綁(如功能/產品)
任何如何做這種轉換的例子? –
@ArchimedesTrajano我提供的鏈接進入一些例子。這基本上是一個問題,或者設置一些額外的細節(再次,請參閱鏈接)的POM文件,然後運行'mvn clean install'或'mvn clean deploy' – Oleksi
我之前看過鏈接,這些例子只顯示瞭如何要爲有問題的pom安裝bundle,它不會告訴你如何包含傳遞依賴。 –