Search code examples
eclipseeclipse-pluginosgiplugin.xml

Are externalised plugin.xml strings available to downstream plugins?


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?


Solution

  • 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);
        }
    }