You can run code reviews on Java source files from a command line
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.
A command line interface allows you to specify your workspace and any optional
parameters. The command line launches a headless Eclipse environment with
only the core features required to run code reviews, and without the user
interface features. By default, it then runs a code review on the source code
in the workspace using either the rules in the Quick code review, or those
that were specified in the UI the last time code review was run.
Before running code reviews in headless mode, you must have a workspace
containing a project with Java source files. The development environment does
not need to be running.
Note: Because of Windows operating system limitations,
the length of the string that is used to run the command line mode (C:\path\java.exe
…) must be as short as possible, or the parameters at the end of the string
could be cut and lost by the system. Windows users should use the following
best practices for optimal results:
- The PATH variable should include as many paths as possible, for example,
the Java path and the path to the JAR files.
- The path to the workspace should be as short as possible, for example,
C:\workspace.
- The path to the location where reports are generated should also be as
short as possible, for example, C:\report.
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.
Example
The following command line runs code review
on a Windows OS from the workspace D:\workspace. An HTML report is produced
in D:\workspace\report.
D:\eclipse\jre\bin\java -Xj9 -Dorg.eclipse.swt.browser.internal.flash
-Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.EPackageRegistryImpl
-cp D:\eclipse\startup.jar org.eclipse.core.launcher.Main -application com.ibm.r2a.command.line.mode.CommandLineModeApplication
-plugincustomization <pluginCustomizationPath> -data <workspace_dir> -reportDirectory
D:\workspace\report -onlyClient CodeReview
Note: You might need to append additional parameters
to the commands in this example for it to run, depending on your
operating system configuration. The parameters are located in the system configuration
details under "System properties" in .