Search code examples
osgimaven-bundle-plugin

Maven Bundle Plugin R6 Metatype


I'm trying to use the maven-bundle-plugin to build a bundle using the osgi r6 metatype annotations.

I have created a config class

@ObjectClassDefinition(
    name = "Bundle State Validator"
)
@interface BundleInstallationConfig {
    boolean DEFAULT_ENABLED = true;

    @AttributeDefinition(
        defaultValue = "true"
    )
    boolean isEnabled() default DEFAULT_ENABLED;
}

and I'm using it in my component class.

@Component(
    immediate = true
)
@Designate(ocd = BundleInstallationConfig.class)
public class BundleInstallationVerifier {
}

but when I build it the generated metatype file doesn't look right and it doesn't load in the config admin. This is what is generated (it's missing the designate section)

<metatype:MetaData localization="OSGI-INF/l10n/test.test.BundleInstallationConfig">
    <OCD id="test.test.BundleInstallationConfig" name="Bundle State Validator" description="Watches bundles to ensure they are in the correct state and switches the System Ready state.">
        <AD id="isEnabled" type="Boolean" name="Is enabled" default="true"/>
    </OCD>
 </metatype:MetaData>

This is the bundle plugin in my pom

       <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.5.4</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <obrRepository>NONE</obrRepository>
                    <_metatypeannotations>*</_metatypeannotations>
                    <_dsannotations>*</_dsannotations>
                </instructions>
            </configuration>
        </plugin>

I have got this far mostly through the frustrations of this guy https://github.com/bndtools/bnd/issues/1030

https://groups.google.com/forum/#!msg/bndtools-users/_F0Nr8b7rlQ/2A9x660pAgAJ


Solution

  • I don't think the maven-bundle-plugin uses bndlib 3.0 yet. bndlib 3.0 (not released yet) is the source of OSGi R6 annotations support. You are a little ahead of things.