views:

71

answers:

2

If I have plugin common, with plugin A and B as separate plugins/products, both depending on plugin common.

In plugin common, I externalise the strings in plugin.xml, this gives me %bundle-vendor = "My Company Name".

In downstream plugins A and B, can I use the common bundle-vendor property for vendor. I tried prepending the common plugin id but it didn't work. Should this be possible?

A: 

As far as I recall the plugin.properties are not available outside the plugin. However you can define a properties type (extending org.eclipse.osgi.util.NLS) to automagically load the properties file and expose them to other plugins.

Each static String property in the type will be processed from the property file(s) according to NLS rules and made available.

Here is a trivial example that will load the properties file and populate the static variables *some_property* and *some_other_property* when the class is loaded.

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);
    }
}
Rich Seller
A: 

Great answer Rich. The only thing I'd add is to ensure that you expose the package/class in the bundle manifest to ensure other bundles can access it.

Lawrence Mandel