2017-04-13 65 views
0

创建自定义karaf分布如何将包添加到karaf Custom Distribution?

<?xml version="1.0" encoding="UTF-8"?> 
<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"> 

    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.me</groupId> 
    <artifactId>root-karaf</artifactId> 
    <packaging>karaf-assembly</packaging> 
    <name>${project.artifactId}</name> 
    <version>4.0.4</version> 
    <dependencies> 
     <dependency> 
      <groupId>org.apache.karaf.features</groupId> 
      <artifactId>framework</artifactId> 
      <version>4.0.4</version> 
      <type>kar</type> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.karaf.features</groupId> 
      <artifactId>standard</artifactId> 
      <version>4.0.4</version> 
      <classifier>features</classifier> 
      <type>xml</type> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.karaf.tooling</groupId> 
       <artifactId>karaf-maven-plugin</artifactId> 
       <version>4.0.4</version> 
       <extensions>true</extensions> 
       <configuration> 
        <!-- no startupFeatures --> 
        <startupFeatures> 

        </startupFeatures> 

        <installedFeatures> 
        </installedFeatures> 
        <bootFeatures> 
         <feature>standard</feature> 
         <feature>eventadmin</feature> 
         <feature>scr</feature> 
        </bootFeatures> 

        <excludedArtifactIds> 
         <artifactId>slf4j-api</artifactId> 
        </excludedArtifactIds> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

现在我想创建例如捆绑,并加入到这个分配或例如补充一点:<bundle>wrap:mvn:com.google.code.gson/gson/2.8.0</bundle> TI rhis分布。我thried这样的:

<bootFeatures> 
         <feature>standard</feature> 
         <feature>eventadmin</feature> 
         <feature>scr</feature> 
         <bundle>wrap:mvn:com.google.code.gson/gson/2.8.0</bundle> 
        </bootFeatures> 

但尼特工作

我feature.xml中创建并投入资源

<?xml version="1.0" encoding="UTF-8"?> 
<features xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="platform-features" 
      xmlns="http://karaf.apache.org/xmlns/features/v1.0.0" 
      xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0 http://karaf.apache.org/xmlns/features/v1.0.0"> 

    <feature name="platform" version="${project.version}" install="auto"> 
     <details>Service Platform</details> 
     <feature>test</feature> 
    </feature> 


    <feature name="test" version="4.0.4" install="auto"> 
     <bundle>mvn:com.google.code.gson/gson/2.8.0</bundle> 
    </feature> 
</features> 

回答

0

AFAIK你不能直接添加捆<bootFeatures>。您应该创建包含此捆绑包的自己的功能,并将该功能添加到bootFeatures。另外,当你创建你的功能时,你不需要wrap:部分! gson 2.8已经是OSGi包了!

+0

谢谢你kep!我创建了futures.xml。我把它放在哪里(文件本身),以及如何连接和配置它,以便从这种未来的捆绑包进入程序集? – user5620472

+0

使用您的功能创建另一个模块,将它作为依赖项添加到您的依赖项列表中,将该功能的名称添加到bootfeatures列表中,然后设置 –