Using PMD with Eclipse
PMD is designed to integrate well into a developer's work environment. Plug-ins exist for the principal IDEs, and they are the most productive and convenient way for a developer to use PMD. Plug-ins allow almost real-time code verificationthey raise issues whenever you save the source code (see
Figure 1).
Installing PMD
The easiest way to install and use PMD under Eclipse is to use the remote update site. From Eclipse, take the following steps:
- Open the Help->Software Updates->Find and Install menu.
- Click Next, and choose New Remote Site.
- Now enter the URL of the remote site (http://pmd.sf.net/eclipse), and an appropriate name such as "PMD" (see Figure 2).
- Now you should have a brand new remote site in your "Update Sites to visit" window (see Figure 3). Make sure you have the PMD site checked in the "Sites to include in search" window, and click Finish. Then just go through the installation screens to install the plug-in.
The plug-in should now be correctly installed. Restart Eclipse if you are asked to. Once that's done, you can set up your projects to use PMD.
Configuring PMD in a Project
You now need to activate PMD for your project. Open the project properties window (
Project->Properties). You will now have a PMD entry (see
Figure 4). This window allows you to configure PMD in detail for your particular project. For now, just check the "Enable PMD" box.