Wrapping Java Libraries as Eclipse Plugins

  1. Create a New Plugin Project

    1. File->New->Project->Plug-in Development->Plug-in Project->Next
    2. Give your project a name. It is common to use the package name as the project name (e.g. org.me.eclipse.lib.thingbeingwrapped)
    3. Click Next
    4. Make sure Create Java project is selected and click Next
    5. Select Create a Blank Plug-in Project and click Next
  2. Add the Java Libraries

    1. Copy all Java archives (.jar) into the project directory (e.g. c:\eclipse\workspace\projectname)
    2. Right-click on the new project and select Properties
    3. Select Java Build Path from the list and then select the Libraries tab
    4. Press the Add JARs button, expand the new project, and select all of the .jar files
    5. Select the Order and Export tab and check-off all of the .jar files you just added
    6. Press OK
  3. Setup the plugin.xml file

    1. Open the plugin.xml file from the new project
    2. Switch to the Source tab below the editor.
    3. You should see a runtime tag containing a library tag:
            <runtime>
              <library name="yourproject.jar"/>
            </runtime>
          
    4. Since this plugin will not expose any new code, that library directive is unnecessary. Modify it to appear as follows:
            <runtime>
              <library name="yourproject.jar">
                <export name="*"/>
                <packages prefixes="your.package.name"/>
              </library>
            </runtime>
          
      Change yourproject.jar to one of the jar files being wrapped.
      If one jar file contains multiple packages the prefixes value should be set to the parent package that contains all of the packages being exposed. For example, if your jar file contains org.foo.utils and org.foo.ui, you would set prefixes="org.foo".
    5. Make a copy of the library tags for each remaining jar file being wrapped
    6. Save the plugin.xml file
      Note: Do NOT try to Compute Build Path on this plugin.xml. Since this project has no code, Eclipse will determine that no dependencies are necessary and remove the JARs from your Build Path
  4. Build the Project

    1. Right-click on the new project and select Build Project
  5. Reference the New Library Plugin from Other Plugins

    1. Open the plugin.xml file from the other plugin.
    2. Select the Dependences tab from beneath the editor.
    3. Click the Add button, select the new library plugin from the list, and click Finish
    4. Right-click anywhere on the Dependencies editor and select Compute Build Path

Copyright (c) 1999-2004, BBN Technologies, LLC. All rights reserved.