You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2018/06/12 18:34:25 UTC
Re: How to add elements to aggregated feature repositories?
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
> That's tricky because users might want different behavior about
> features repositories dependencies.
> As already mentioned, it gives more control to write the features
> repository XML by hand and verify using the plugin.
Do you have an example of a project doing this?
I basically just need to expand maven properties for version numbers in
a template file, and install the expanded feature as a maven artifact
(whether as an attachment to the POM or as a feature artifact in its own
right).
Re: How to add elements to aggregated feature repositories?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
[snip!]
>> As already mentioned, it gives more control to write the features
>> repository XML by hand and verify using the plugin.
[snip!]
> I basically just need to expand maven properties for version numbers
> in a template file, and install the expanded feature as a maven
> artifact (whether as an attachment to the POM or as a feature artifact
> in its own right).
Ok, now I've got it working.
I just created a feature.xml file that references the bundles'
repositores, but with ${project.version} in place of the version, then I
created maven configuration for the parent pom that expanded the
feature.xml file and attached the expanded file to the parent POM.
Advantages to my old approach of letting karaf-maven-plugin generate an
aggregated feature repository from dependencies to the bundle projects'
feature repositories:
1. It's actually simpler
2. The <repository> references of the referenced <repositories> are
preserved (ie. all the necessary repositories are loaded into karaf)
3. I can stop having a special maven module just to build the
aggregated feature repository, and instead just attach this feature
repository to the parent POM of a multi-module project
This is an example project that has two bundles that generate their own
feature repositories and a parent POM that has an aggregated feature
repository for the two bundles' repositories as an attachement:
https://github.com/steinarb/whiteboard-web-and-api-karaf-demo
The resource feature file that becomes the attachment after expansion,
is here:
https://github.com/steinarb/whiteboard-web-and-api-karaf-demo/blob/master/src/main/filtered-resources/feature.xml
and looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="webapi">
<repository>mvn:no.priv.bang.demos.whiteboardwebapi/webapi/${project.version}/xml/features</repository>
<repository>mvn:no.priv.bang.demos.whiteboardwebapi/webgui/${project.version}/xml/features</repository>
</features>
The maven config that filters the feature.xml file and attach the
filtered file (note the not-inherited setting on the attachment) is here:
https://github.com/steinarb/whiteboard-web-and-api-karaf-demo/blob/master/pom.xml#L149
and looks like this:
<project>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>filter-resources</id>
<phase>validate</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/filtered-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<inherited>false</inherited>
<executions>
<execution>
<id>attach-karaf-feature</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/classes/feature.xml</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>