简体   繁体   中英

Inserting Karaf Archive dependencies in features file to create Karaf Archive

I have a Java project using Maven and I'm using Karaf 3.0.4. I create .kar files using a Maven plugin :

  <groupId>org.apache.karaf.tooling</groupId>
    <artifactId>features-maven-plugin</artifactId>
    <version>2.4.3</version>
    <executions>
       <execution>
          <id>create-kar</id>
          <goals>
             <goal>create-kar<goal>
          </goals>
          <configuration>
             <featuresFile>path/toMy/featureFile.xml</featuresFile>
          </configuration>
       </execution>
    </executions>

In this featureFile.xml , I add the necessary features and bundles dependencies ; it's working fine : the .kar file is created.

Now, I'd like to add Karaf Archive dependencies in this .xml file but I didn't find a way to do it. I was expecting someting like :

<feature name="myFeature" version="1.0" install="manual">
   <feature>anotherFeature</feature>
   <bundle>path/to/aBundle</bundle>
   <kar>path/to/aKarafArchive</kar>
</feature>

Do you have an idea ? Is it possible ?

Edit

Here is my featureFile.xml

<?xml version="1.0" encoding="UTF-8"?>
<features name="featureFile" xmlns="http://karaf.apache.org/xmlns/features/v1.2.1">

    <feature name="aFeature" description="Simple example" version="1.0" install="manual">
        <feature>CodeHaus</feature>
        <bundle>mvn:org.testng/testng/6.8.8</bundle>
    </feature>

    <feature name="CodeHaus" description="">
        <details>Get CodeHaus bundles</details>
        <bundle>mvn:org.codehaus.jackson/jackson-core-asl/1.9.2</bundle>
        <bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.2</bundle>
    </feature>

</features>

I have 3.0.0.RC1 installed. Check the standard feature file inside

Karaf_root\\system\\org\\apache\\karaf\\features\\standard\\3.0.0.RC1\\standard-3.0.0.RC1-features.xml

For you it should show a different version.

Karaf_root\\system\\org\\apache\\karaf\\features\\standard\\${karaf-version}\\standard-${karaf-version}-features.xml

There's an entry here for Karaf Archive feature.

<feature resolver="(obr)" description="Provide KAR (KARaf archive) support" version="3.0.0.RC1" name="kar">
    <bundle start-level="30">mvn:org.apache.karaf.kar/org.apache.karaf.kar.core/3.0.0.RC1</bundle>
    <bundle start-level="30">mvn:org.apache.karaf.kar/org.apache.karaf.kar.command/3.0.0.RC1</bundle>
    <bundle start-level="30">mvn:org.apache.karaf.deployer/org.apache.karaf.deployer.kar/3.0.0.RC1</bundle>
</feature>

You can use the same in your feature XML file.

Edited*

File system JAR path can be given like below

<?xml version="1.0" encoding="UTF-8"?>
<features name="MyFeaturesRepo">
  <feature name="example-camel-bundle">
    <bundle>file:C:/Projects/camel-bundle/target/camel-bundle-1.0-SNAPSHOT.jar</bundle>
    <feature version="6.0.0.redhat-024">camel-core</feature>
    <feature version="6.0.0.redhat-024">camel-spring-osgi</feature>
    <feature version="6.0.0.redhat-024">servicemix-camel</feature>
  </feature>
</features>

Source:

https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/Deploying_into_the_Container/files/DeployFeatures-Create.html

It's from JBoss Fuse, but I think it should work for plain Karaf too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM