Thursday, April 27, 2006

Re-installing PMD Eclipse Plugin

It has happened on more than one occasion that the Eclipse PMD plugin has gotten well and truly messed up. Through trial and error, I can recommend the following actions as a cure to an ill installation of the PMD plugin.
  1. Open up Eclipse.
  2. If you have the PMD perspective open, close it.
  3. On the "Help" menu, click "Software Updates", then "Manage Configuration"
  4. Expand the "c:\eclipse" (assuming that's where it's installed) option
  5. You should see "PMD for Eclipse 3 x.x.x" or "PMD for Eclipse 2 x.x.x"
  6. Click on whatever PMD plugins are listed and click the disable link in the right-hand pane.
  7. When asked "Do you want to disable this feature?" click "OK"
  8. Restart the Workbench as requested
  9. Repeat steps 3 and 4
  10. You should not be able to see the PMD plugin listed. To see all disabled plugins, click the "Show Disabled Features" button.

  11. The PMD plugin should now be listed.
  12. When you click on the PMD plugin, the right-hand pane will give you the option to Uninstall the plugin. Click the Uninstall Link
  13. When prompted "Do you want to uninstall this feature", click OK.
  14. Restart the workbench as suggested.
  15. For a clean installation of PMD, some extra steps must be taken.
    1. Close Eclipse and run the Eclipse.exe file with the -clean switch. This will remove any old PMD manifests.
    2. Within your Eclipse directory, there will be directories for each of your projects. Within these project directories, PMD may have stored settings related to the plugin. You need to delete these files.
    3. Delete any files with PMD in their name or having a ".pmd" extension.
      Obviously if you have source code that you yourself have written with PMD in the filename, then do not delete those files.
    4. Repeat step 1.
  16. Now we can re-install the plugin. With Eclipse open, click "Help" -> "Software Updates" and then "Find and Install"
  17. Select the "Search for new features to Install" option and click "Next"
  18. To be completely safe you should remove any references to PMD sites you have already defined. You can do that by highlighting the site and then clicking the "Remove" button.
  19. Once you have removed all PMD related sites, click the "New Remote Site" button.
  20. Enter PMD (or whatever catches your fancy) for the name, and http://pmd.sourceforge.net/eclipse for the site. Then click "OK"
  21. Your PMD site should now be listed. Tick the check box beside it and click "Finish"
  22. Eclipse should find the PMD plugin. Tick the checkbox beside it and click "Next"
  23. Accept the terms of the license agreement (If you like) and click "Next"
  24. You can then accept the default install location or choose your own. Once you've done that, click "Finish"
  25. The PMD plugin will then be downloaded in the background.
    BE WARNED!
    The sourceforge servers seem to be as reliable as a '78 Lada Riva 2000 (not very). The speed that the plugin downloads can vary so give it time. Also sometimes you can get an "Exception Occured" error. It will ask you if you would like to retry the download, and I suggest you do so.
  26. Once it has been downloaded, click the "Install" button.
  27. Restart the workbench as suggested.
  28. A good indicator of whether the install has succeeded is to do the following
    1. Click "Window" -> "Preferences".
    2. Select the PMD preferences option and expand it.
    3. Click the "Rule Configuration" option.
    4. If the install has succeeded, you should see add/import/export rules and a list of available rules.
      If the install failed then you'll see a big grey area where the rule options should be. Maybe you'll get an error message if you're lucky.
    5. The key cause of the error message is not deleting the pmd files stored in the project directory, as mentioned in step 15. Check and double-check that all PMD related files have been deleted.
  29. Start using PMD!
That took a hell of a lot longer than I expected.....

1 Comments:

Blogger Unknown said...

Thanks. Saved me a lot of hassle.

12:22 pm

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home