You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "Sergey N. Zaitsev" <se...@gmail.com> on 2008/03/03 19:30:17 UTC

problem with maven bundle plugin

Hi,

It seems that bundle plugin incorrectly packaging resources.
I have two property files containing externalized text, one of them
should be converted from utf to ascii (simple native2ascii ant task
by means of maven-antrun-plugin). Converted property file stored to
target/classes directory but it is not get included into packaged bundle.
When I changed packaging type from 'bundle' to 'jar', I found that
converted property file added to final jar.
 
You can try to 'mvn package' attached project to see the problem described
above (check OSGI-INF/l10n/bundle_ru)

-- 
Regards,
Sergey.


Re: problem with maven bundle plugin

Posted by Stuart McCulloch <st...@jayway.net>.
On 04/03/2008, Sergey N. Zaitsev <se...@gmail.com> wrote:
>
> Hi,
>
> It seems that bundle plugin incorrectly packaging resources.
> I have two property files containing externalized text, one of them
> should be converted from utf to ascii (simple native2ascii ant task
> by means of maven-antrun-plugin). Converted property file stored to
> target/classes directory but it is not get included into packaged bundle.
> When I changed packaging type from 'bundle' to 'jar', I found that
> converted property file added to final jar.


Hi Sergey,

Yes, the bundleplugin uses a selective process to generate a bundle
- it does not simply jar up the contents of target/classes, but instead
you give it instructions on what content to "pull" into the bundle.

This is because the Bnd tool (which is used in the bundleplugin) was
designed to help separate a project classpath into different bundles.

By default, the bundleplugin will add Maven resources by translating
the <resource> entries into a Bnd instruction, <Include-Resource>.
I see in your pom.xml that you exclude the _ru properties file - this
means that Bnd won't add it automatically to the bundle, because
it follows the same filter rules as Maven for copying resources.

( although if it wasn't excluded Bnd would just add the resource from
  the src/main/resources, not the processed file from target/classes )

To add the processed properties file, I would suggest the following:

first, add this to the bundleplugin instructions:

   <Include-Resource>{maven-resources},target/properties</Include-Resource>

this tells Bnd to copy the contents of the target/properties folder to
the bundle root (after copying any maven resources) - for more info
on this instruction, see http://aqute.biz/Code/Bnd#include-resource

second, change the ant task to use the 'target/properties' location:

   <native2ascii encoding="UTF-8" dest="target/properties" ... />

and you should have the translated properties file in the bundle.

HTH

You can try to 'mvn package' attached project to see the problem described
> above (check OSGI-INF/l10n/bundle_ru)
>
> --
> Regards,
>
> Sergey.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart