Running code reviews from an Ant script

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:
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:
  1. Select File > New > File.
  2. Enter build.xml as the name of the Ant script and click Finish.
  3. Double-click the build.xml Ant script to open the Ant editor.
  4. 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>
  5. 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\\".
  6. Close the Ant editor.
  7. To run the Ant script, right-click the build.xml file, select Run > External Tools > External Tools 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.
Related concepts
Code reviews run in headless mode
Related reference
Code review headless mode reference
Quick code review
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.