Robert Munteanu
Robert Munteanu

Reputation: 68278

Optional extension points in plugin.xml

I want to define an extension point in my plugin.xml which is not available in my target platform. This is fine for me, because I want to take advantage of it only if it's available .

However ,when I add it Eclipse flags it with an error

Unknown extension point: 'org.eclipse.ui.trace.traceComponents'

Can I somehow mark this extension point as optional? I know that I can reduce the Unresolved extension points severity per-workspace or per-project, but I'd rather not do that for just one error.

The complete plugin.xml is

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

   <extension
         id="org.apache.sling.slingclipse.preferences"
         name="Slingclipse Preferences"
         point="org.eclipse.ui.preferencePages">
      <page
            name="Slingclipse"
            class="org.apache.sling.slingclipse.preferences.SlingclipsePreferencePage"
            id="org.apache.sling.slingclipse.preferences.defaultPreferences">
      </page>
   </extension>
   <extension
         point="org.eclipse.core.runtime.preferences">
      <initializer
            class="org.apache.sling.slingclipse.preferences.PreferenceInitializer">
      </initializer>
   </extension>
   <extension
         point="org.eclipse.ui.startup">
      <startup
            class="org.apache.sling.slingclipse.SlingclipseStrartup">
      </startup>
   </extension>
   <extension
         point="org.eclipse.ui.importWizards">
      <category
            id="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
            name="Sling">
      </category>
      <wizard
            category="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
            class="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
            icon="icons/sample.gif"
            id="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
            name="Import from Repository">
         <description>
            Import a file from the local file system into the workspace.
         </description>
      </wizard>
   </extension>
   <extension
         point="org.eclipse.ui.trace.traceComponents">
      <component
            id="org.eclipse.ui.trace.tracingPrefPage"
            label="Slingclipse">
         <bundle
               name="org.apache.sling.slingclipse"></bundle>
      </component>
   </extension>
</plugin>

Upvotes: 2

Views: 1476

Answers (1)

Bananeweizen
Bananeweizen

Reputation: 22070

You are mixing two concepts here: Development time versus runtime.

Extension points are dependencies declared at development time. Therefore you should have the plugin defining that extension point in your target platform at development time. But you are right, you can generally write the manifest XML for extending that extension point without it being available. In practice this does not work well because many extension points require to implement an interface which itself is also defined in the (non existing) plugin.

To make the functionality be optional for a user (and to not force him to have the defining plugin), you need to make the installation of your plugin optional. But that is not related to the manifest and the use of extension points at all. E.g. you have to declare a feature containing your plugin and make that feature depend on the feature containing the plugin defining the extension point.

Upvotes: 2

Related Questions