2

如果我有插件通用,插件 A 和 B 作为单独的插件/产品,两者都取决于插件通用。

在插件通用中,我将 plugin.xml 中的字符串外部化,这给了我 %bundle-vendor = "My Company Name"。

在下游插件 A 和 B 中,我可以使用常见的 bundle-vendor 属性作为 vendor. 我尝试在公共插件 id 前面加上它,但它没有用。这应该可能吗?

4

2 回答 2

0

据我记得 plugin.properties 在插件之外不可用。但是,您可以定义一个属性类型(扩展 org.eclipse.osgi.util.NLS)来自动加载属性文件并将它们公开给其他插件。

类型中的每个静态字符串属性都将根据 NLS 规则从属性文件中处理并使其可用。

这是一个简单的示例,它将加载属性文件并在加载类时填充静态变量some_propertysome_other_property 。

public class ContentMessages extends NLS {

    private static final String BUNDLE_NAME = 
        "name.seller.rich.content.messages"; //$NON-NLS-1$

    public static String some_property;
    public static String some_other_property;

    static {
        // load message values from bundle file
        reloadMessages();
    }

    public static void reloadMessages() {
        NLS.initializeMessages(BUNDLE_NAME, ContentMessages.class);
    }
}
于 2009-08-23T18:51:04.593 回答
0

很好的答案里奇。我唯一要添加的是确保您在捆绑清单中公开包/类,以确保其他捆绑可以访问它。

于 2010-01-08T20:44:51.990 回答