javamavenosgiosgi-bundlemaven-bundle-plugin

Declare resource included by maven-bundle-plugin as optional


I have a multi-module build creating multiple artifacts with package type "bundle".

Some of them create some information in the META-INF directory during compile time, some don't.

I tried to define an instruction in the parent pom.xml that adds the META-INF directory as a resource to the bundle. Unfortunately this fails for those artifacts not creating the META-INF directory during the build time.

I tried to avoid defining this rule on all modules that currently DO creating the META-INF directory since

Is it somehow possible to make this "include-resource" instruction optional, meaning it ignores this resource if it's missing?

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>3.5.0</version>
    <configuration>
        <instructions>
            <Include-Resource>META-INF=${project.build.outputDirectory}/META-INF</Include-Resource>
        </instructions>
    </configuration>
</plugin>

Solution

  • Prefixing the resource pattern with - should suffice, e.g.:

    <Include-Resource>-META-INF=${project.build.outputDirectory}/META-INF</Include-Resource>
    

    Documentation here.