You can run code reviews in a "headless" workbench (with no user
interface for the development environment). This can be useful if you want
to run code reviews unattended, on a regular basis, or if you want to include
them in an Ant script.
Before running code reviews in headless mode:
- The workspace must contain at least one project with Java source files.
- If you want to specify the rules that run, you must configure the code
review in the user interface.
Note: You cannot run several executions of code review in headless mode
on the same workspace at the same time, nor can you use headless mode while
an Eclipse graphical user interface has locked the workspace.
To create and run an Ant script:
- Select .
- Enter build.xml as the name of the Ant script
and click Finish.
- Double-click the build.xml Ant script to open
the Ant editor.
- Enter the following content in the editor:
<?xml version="1.0" encoding="UTF-8">
<project name="MyTestProject" default="CodeReviewHeadless" >
<target name="CodeReviewHeadless">
<property name="eclipse_dir" value="D:\\eclipse"/>
<property name="workspace_dir" value="D:\\workspace"/>
<property name="options" value=" -plugincustomization <pluginCustomizationPath> -onlyClient CodeReview -reportDirectory ${workspace_dir}\\batch_report -timeStampMode"/>
<exec executable="${eclipse_dir}/jre/bin/java" dir="${eclipse_dir}" vmlauncher="false">
<arg line=="-Xj9 -Dorg.eclipse.swt.browser.internal.flash -Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.EPackageRegistryImpl -cp ${eclipse_dir}/startup.jar org.eclipse.core.launcher.Main -application com.ibm.r2a.command.line.mode.CommandLineModeApplication -data ${workspace_dir} ${options}" />
</exec>
</target>
</project>
- Replace the property values of eclipse_dir and workspace_dir with
the actual Eclipse installation directory and the workspace directory. Add
any additional options to the options property value. Use double quotes when the path contains spaces. For Windows, use double
backslashes (\\) instead of the backslash character.
Here is an example: "C:\\Program Files\\IBM\\Rational\\".
- Close the Ant editor.
- To run the Ant script, right-click the build.xml file,
select and click Run. This launches a new instance of the Eclipse environment in headless
mode, which will run the code review launch configurations located in the
specified workspace. You can also run the Ant script from a command line by
using the runAnt command.
The results of the code review are generated in a report directory
located in the workspace.