Karaf-maven-plugin: defining dependency as a function

I am trying to get karaf-maven-plugin to create a function file for my application. The application depends on the cxf function, but I cannot get the plugin to generate the xml function to reflect this.

Cutout from my function module:

<dependencies> <dependency> <groupId>com.test.test</groupId> <artifactId>test</artifactId> </dependency> </dependencies> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.karaf.tooling</groupId> <artifactId>karaf-maven-plugin</artifactId> <version>3.0.3</version> <extensions>true</extensions> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.karaf.tooling</groupId> <artifactId>karaf-maven-plugin</artifactId> <configuration> <startLevel>80</startLevel> <includeTransitiveDependency>true</includeTransitiveDependency> <aggregateFeatures>false</aggregateFeatures> </configuration> </plugin> </plugins> </build> 

Dependencies on my module:

  <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <version>5.0.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> <version>5.0.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.configadmin</artifactId> <version>1.8.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <!-- use extension providers --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-extension-providers</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <!-- use Jackson --> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-jaxrs</artifactId> <version>1.9.13</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-xc</artifactId> <version>1.9.13</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-ws-security</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-ws-policy</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-ws-addr</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-hc</artifactId> <version>${cxf.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.cxf.karaf</groupId> <artifactId>apache-cxf</artifactId> <version>${cxf.version}</version> <classifier>features</classifier> <type>xml</type> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> </dependency> </dependencies> 

As you can see, I tried to define the artifact of the function as a compilation-dependent area, as well as commons lang. Everything else is limited as provided.

  <dependency> <groupId>org.apache.cxf.karaf</groupId> <artifactId>apache-cxf</artifactId> <version>${cxf.version}</version> <classifier>features</classifier> <type>xml</type> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> </dependency> 

The commons package is registered in the resulting features.xml file, but the function is missing:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="feature"> <feature name="feature" version="0.1-SNAPSHOT" description="test-feature"> <details>test</details> <bundle start-level="80">mvn:com.test.test/test/0.1-SNAPSHOT</bundle> <bundle start-level="80">mvn:org.apache.commons/commons-lang3/3.3.2</bundle> </feature> </features> 

I would like to end up with:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="feature"> <feature name="feature" version="0.1-SNAPSHOT" description="test-feature"> <details>test</details> <feature version="3.0.2">cxf</feature> <bundle start-level="80">mvn:com.test.test/test/0.1-SNAPSHOT</bundle> <bundle start-level="80">mvn:org.apache.commons/commons-lang3/3.3.2</bundle> </feature> </features> 

Small update: When I add <aggregateFeatures>true</aggregateFeatures> to the plugin configuration, the whole cxf function is unpacked into my features.xml file, but function dependencies like "cxf" still do not appear in the genetic function.

+5
source share
1 answer

IMHO this is something wrong or not completed in karaf-maven-plugin. I had the same problem. For me, the solution I found is to add the feature.xml template to src / main / feature, just with the functions and other configfiles I need. In your case, it will be something like this:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="feature"> <feature name="feature" version="${yourprojectversion}" description="test-feature"> <feature version="${cxf.version}">cxf</feature> </feature> </features> 

I also use: <aggregateFeatures>true</aggregateFeatures>

Please note that in my property template I use some custom maven properties for version handling defined in pom.xml. In the end, you will get the function that you expect.

+6
source

All Articles