Anshul Singhal
Anshul Singhal

Reputation: 2201

How to exclude a bundle from Karaf Feature programatically

In my project, there is Karaf feature XML file contains all OSGi bundles. Now, this is used as dependency in other maven project's pom.xml file.

<dependency>
  <groupId>a.b.c</groupId>
  <artifactId>dummyfeature</artifactId>
  <type>xml</type>
  <classifier>features</classifier>
  <version>1.0.0</version>
</dependency>

Now, following code is being used to install above feature.

KarafDistributionOption.features(
                 maven()
                .groupId("a.b.c")
                .artifactId("dummyfeature")
                .version("1.0.0")
                .type("xml")
                .classifier("features"), "dummyfeature")

Is there a way to exclude a particular OSGi bundle from above feature programtically?

Upvotes: 1

Views: 2359

Answers (1)

Grzegorz Grzybek
Grzegorz Grzybek

Reputation: 6237

https://issues.apache.org/jira/browse/KARAF-5376 provides a way to alter the features read from XML file. You can:

  • blacklist some bundles
  • blacklist some features
  • override some bundles (like changing version or even group/artifact IDs)
  • override entire features

See this comment for overview of the mechanism. There's no documentation fragment yet (I didn't have time to do it). But for your particular case, you should add etc/org.apache.karaf.features.xml file with this content:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Configuration generated by Karaf Assembly Builder
-->
<featuresProcessing xmlns="http://karaf.apache.org/xmlns/features-processing/v1.0.0">
    <blacklistedBundles>
        <!-- there are several patterns you can use here -->
        <bundle>mvn:groupId/artifactId</bundle>
        <bundle>mvn:groupId/artifactId/1.0</bundle>
        <bundle>mvn:groupId/artifactId/[1,2)</bundle>
    </blacklistedBundles>
</featuresProcessing>

Upvotes: 3

Related Questions