1

我正在尝试使用maven-bundle-pluginosgi r6 元类型注释来构建包。

我创建了一个配置类

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

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

我在我的组件类中使用它。

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

但是当我构建它时,生成的元类型文件看起来不正确,并且它没有加载到配置管理中。这是生成的(它缺少指定部分)

<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>

这是我的 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>

我主要是通过这个家伙的挫败感来做到这一点的 https://github.com/bndtools/bnd/issues/1030

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

4

2 回答 2

3

我认为还没有maven-bundle-plugin使用 bndlib 3.0。bndlib 3.0(尚未发布)是 OSGi R6 注释支持的来源。你有点超前了。

于 2015-08-28T20:01:45.317 回答
-1

designate没有出现,因为尚未在类中定义一个。看看 Neil Bartlett 关于这个主题的帖子:在此处输入链接描述

于 2015-12-14T15:06:15.430 回答