eclipse-cs Banner SourceForge.net Logo Support This Project

-- Extending the plug-in - The advanced way --

A more Eclipse conforming way to extend the Checkstyle plug-in would be to provide a so called fragment.
Fragments are extensions to a plug-in that get merged in to the original plug-in - so these fragments get basically integrated into the plug-in as if they were part of the original plug-in.
This mean they have no life cycle on their own but share the life cycle of the plug-in they extend.

While just copying some jars into the plug-in directory is a very simple way to extend the Checkstyle plug-in, providing a fragment for custom checks is more complicated, but gives you some other powerful options:

  • Your extension to the plug-becomes self contained - no need to copy anything into the plug-in directory

  • You can provide an update site to deliver the fragment to your users

  • You can make use of the extension-points the Checkstyle plug-in provides (for filters, built-in configurations etc.)

So here are the steps for creating a fragment that adds a custom check library to the Checkstyle plug-in:

  1. Create your custom .jar like described here .
  2. Create a new fragment project

    Fragment Project                         Wizard

    Fragment Project                         Wizard

    Fragment Project                         Wizard
    Choose the Checkstyle plug-in from the list of plug-ins that appears when you hit the Browse... button.
    Finish creating the fragment project by pressing Finish.

  3. Copy your jar file containing you custom checks into the fragment project

    Project View

  4. Open the MANIFEST.MF file and add your custom library to the fragments classpath

    Manifest editor
    Don't forget to save the manifest editor.

  5. To "build" your fragment simply use the export wizard

    Export wizard

    Export wizard

  6. Install the fragment to your Eclipse just like you would install a plug-in

  7. (Re)start your eclipse with the -clean option to make sure the changes get picked up