我正在尝试使用maven-bundle-plugin
osgi 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