Eclipse Plugin Fragment

  1. Eclipse -> File -> New… -> Fragment project -> set the host plugin (which is either in your workspace or in plugins in target platform).

  2. Open Plugin manifest editor (you can do it by clicking on build.properties, manifest.mf or fragment.xml – if there is no such a file, create it by hand)

  3. In tab Extentions click Add.. and add org.eclipse.ui.startup and browse class which implements org.eclipse.ui.IStartup class.

  4. Create this class and implement it. You need to implement method earlyStartup() which is entry point to the fragment.

Note: The lines below are just example. I didn’t test it so there might be errors…

All you need is this (this is project structure / directory structure):

  • Fragment-Project – root dir
    • /META-INF
      • MANIFEST.MF
    • /src (which is source directory)
      • FragmentStartClass.java (which implement org.eclipse.ui.IStartup interface and earlyStartup method)
    • build.properties
    • fragment.xml

META-INF/MANIFEST.MF content:

Manifest-Version: 1.0 
Bundle-ManifestVersion: 2 
Bundle-Name: FragmentProject 
Bundle-SymbolicName: FragmentProject;singleton:=true 
Bundle-Version: 1.0.0 
Bundle-ClassPath: src/,. 
Fragment-Host: *HostPluginProjectSymbolicName*;bundle-version="1.0.0" 
Bundle-RequiredExecutionEnvironment: J2SE-1.5 
Require-Bundle:  

build.properties content:

source.. = src,\
output.. = bin/
bin.includes = META-INF/,
              .,
                  fragment.xml

fragment.xml content:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<fragment>
   <extension
         point="org.eclipse.ui.startup">
      <startup
            class="FragmentStartClass">
      </startup>
   </extension>
</fragment>

FragmentStartClass.java content:

import org.eclipse.ui.IStartup;


public class FragmentStartClass implements IStartup {

    public void earlyStartup() {
       System.out.println("Hello World From Fragment!");

    }


}

Leave a Comment