Hi!
I have a maven project containing several modules and external feature
dependencies (e.g. cxf-dosgi feature), running in Karaf 2.3.2, which
will need to be deployed and updated offline (with no internet
access). Using features and kar files seems to be a perfect fit, but
I'm having trouble working with them. Here are my attempts and
results, which I hope someone can help me with.
At first I tried plugin version 2.3.2, to match the Karaf version I'm
on (also tried earlier versions while trying to check some of the
issues, but the result was the same).
1. Trying to use the generate-features-xml goal as described in
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/features-maven-plugin-generate.html
resulted in an error:
[ERROR] Failed to execute goal
org.apache.karaf.tooling:features-maven-plugin:2.3.2:generate-features-xml
(generate) on project server: Unable to create features.xml file:
org.apache.maven.artifact.resolver.ArtifactNotFoundException: Failure
to find org.eclipse:osgi:jar:3.8.0.v20120529-1548 in
http://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced
2. Running the create-kar goal with a manually created features.xml
file works, but... the external dependency features seem to be ignored
- no separate kars are generated from them, and they are not embedded
in the main project kar (it would be nice to have both of these as
options).
3. I tried manually adding executions to create kar files for the
external features, but neither a mvn url or a full http url work - it
appears the featuresFile parameter supports only a local file. So
what's the proper way to get the external features into kars
(individual or embedded) for offline deployment?
Next, I tried my luck with the newer karaf-maven-plugin (currently
released only in version 3.0.0.RC1), using docs at
http://karaf.apache.org/manual/latest/developers-guide/karaf-maven-plugin.html.
4. The features-generate-descriptor goal no longer has the
kernelVersion parameter that the old generate-features-xml had - how
does it decide which bundles/features are installed by default and
should not be included as duplicates?
5. Setting aggregateFeatures and includeTransitiveDependency to true,
the external dependency features still seem to be ignored.
6. I did hit KARAF-1972 though, which is still unresolved. I'm not
sure yet if this is just ugly but will work, or if it might actually
cause trouble when deployed (in my case it included osgi core and
compendium bundles in the kar).
7. It seems the new recommended way of doing things in the new plugin
is via <packaging>kar</packaging>. However when I tried changing the
packaging from pom to kar I get an error:
[ERROR] Failed to execute goal
org.apache.karaf.tooling:karaf-maven-plugin:3.0.0.RC1:features-create-kar
(default-features-create-kar) on project server: Execution
default-features-create-kar of goal
org.apache.karaf.tooling:karaf-maven-plugin:3.0.0.RC1:features-create-kar
failed: For artifact {com.example.server:server:0.1-SNAPSHOT:kar}: An
attached artifact must have a different ID than its corresponding main
artifact. -> [Help 1]
(the ID is unique, and I tried changing it too, but still get this
error. I do have extensions set to true, fwiw.)
A couple more things that made my attempts a bit less fun:
8. Some documentation/website typos I came across:
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/features-maven-plugin.html
- the link to create-kar goal in the table at the top of the page is
messed up.
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/branding-console.html
- user variable is shown as $}, which I'm guessing is a typo.
http://karaf.apache.org/manual/latest-2.3.x/users-guide/provisioning.html
- last link (to custom build) is broken.
http://karaf.apache.org/manual/latest-2.3.x/developers-guide/features-maven-plugin-create-kar.html
- a parameter named {{resourcesDir} is probably a typo. Also the
default parameter values look fishy (I've seen this elsewhere too).
It looks like those and other typos revolve around invalid use of
curly braces - perhaps you can set up a regex to detect the invalid
usages and fail the website build accordingly, or at least run a
one-time grep and fix all of those.
9. The docs, examples and configuration parameters and default values
use feature.xml/features.xml/feature repository interchangeably, which
is a bit confusing until one reads enough to realize they're all the
same. It would be clearer to pick a standard xml name and standard
terminology for it and be consistent everywhere.
So, can anyone help understand/document/workaround/fix any of these?
And is there any way to get external features into kars for offline
deployment? I'm aware of the alternative of building a custom
pre-installed karaf distribution, though I haven't gone down that path
yet - I'm still hoping kars are usable since they seem to better fit
my needs.
Thanks!
Amichai