views:

596

answers:

1

I'm using Maven and its assembly plugin to build a distribution package of my project like this:

  • one project assembles a basic runtime (based on Felix), with the appropriate directories and bundles, in a ZIP file.
  • third-party libraries are collected in one project each and either converted to OSGi bundles or, if they are already OSGi compatible, they are just copied
  • my own project consists of several modules that are built into OSGi bundles, too.

Now, I'm adding another project that unpacks the ZIP, drops all the other JARs into the proper directories, and repackages it for distribution. Now, my bundles might contain configuration files that I want to merge into, rather than replacing, identically named ones in the runtime assembly. How do I do that?

The files are plain text (property files), but I might run into a similar situation with XML files later.

+3  A: 

I don't know of a robust solution to this problem. But a bit of looking around shows that somebody has created a plugin to merge properties files. By the look of it you need to tell it which files to merge, which is a good thing as you don't want this applied willy nilly.

Assuming you have used dependency-unpack to unpack the zip to a known location, it would be a case of configuring the plugin to merge each pair of properties files and specify the appropriate target location.

You could extend the plugin to handle XML by using something like xmlmerge from EL4J, as described in this Javaworld article.

Rich Seller
Cool, will look into that.
Hanno Fietz
The plugin actually seems to work great!
Hanno Fietz
glad it works, it might come in handy for me too
Rich Seller
+1 thanks for pointing this out
Pascal Thivent
The plugin is actually made by me. Nice to see it has become useful for someone.
hleinone