Running a code review as an Ant task

You can run a code review when you build an Eclipse plug-in in the plug-in development environment (PDE) by adding an Apache Ant task to the plug-in's build.xml file.

To run a code review from the command line, you must create a rules file.
The analysis.analyze Ant task provides a convenient method to run a code review as part of a complete build process for plug-ins you develop in the PDE. You can configure the PDE project builder to run the Ant task whenever you build the project and whenever you clean the project and rebuild from scratch.

To run a code review as an Ant task:

  1. Verify that the analysis.analyze Ant task is registered.
    1. Click Window > Preferences
    2. In the Preferences window, click Ant, then click Runtime.
    3. In the Runtime pane, click the Tasks tab and verify that the analysis.analyze Ant task is listed in the Name column.
  2. If the plug-in project does not have an Ant build file, in the Package Explorer view, right-click the project name; then click PDE Tools > Create Ant build file
  3. Open the build.xml file and add the following Ant target:
    <target name="code review">
      <analysis.analyze projects="project name"
                        rulefile="path to rules file" />
  4. Test the target: in the Outline view, right-click the target name (for example, code review); then click Run as > Ant Build. The Console view displays the results of the code review.
  5. Create a builder for the Ant task.
    1. In the package Explorer view, cick the PDE project; then click Projects > Properties
    2. In the Properties window, in the left pane, click Builders; then click New.
    3. In the Choose configuration type window, click Ant build; then click OK
    4. In the Properties for new builder window, on the Main page, click Browse Workspace
    5. In the Choose Location window, click the name of a PDE project; then click build.xml, and click OK.
    6. On the Targets page, for the After a "Clean" setting, click Set Targets.
    7. In the Set Targets window, clear the build.jars setting
    8. Repeat substep 5.f and substep 5.g for the Manual builds setting.
    9. In the Properties for new builder window, type a name for the builder (for example, code review), and click OK.
  6. In the PDE perspective, click Project > Build Project.
The results of the code review display in the Console view.
Related concepts
Code reviews
Ant task code review
Rules and rule categories