Script de Windows

El componente Revisión de código proporciona un script de ejemplo para ejecutar la aplicación de revisión de código desde una línea de mandatos de Windows.

El bloque de código siguiente muestra el script Windows:

Figura 1. codereviewbatch.bat
@setlocal
@echo off

:: ============================================================================
::  IBM Rational Developer for System z 5724-T07
:: 
::  Copyright IBM Corp. 2012 All rights reserved.
::  All rights reserved. US Government Users Restricted Rights - 
::  Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
::  IBM Corp.
:: ============================================================================

set rdz_install_dir=@RDZINSTALLDIR@

:: supply defaults if desired; use quotes around paths containing spaces
set workspace=
set rulefile=
set exportdir=
set directory=
set projects=
set includefile=
set excludefile=
set outputfile=
set debug=

:: handle parameters
:setOptions
if [%1[==[-workspace[ (set workspace=%2& shift /1 & shift /1 & goto setOptions)
if [%1[==[-rulefile[ (set rulefile=%2& shift /1 & shift /1 & goto setOptions)
if [%1[==[-exportdir[ (set exportdir=%2& shift /1 & shift /1 & goto setOptions)
if [%1[==[-directory[ (set directory=%2& shift /1 & shift /1 & goto setOptions)
if [%1[==[-projects[ (set projects=%2& shift /1 & shift /1 & goto setOptions)
if [%1[==[-includefile[ (set includefile=%2& shift /1 & shift /1 & goto setOptions)
if [%1[==[-excludefile[ (set excludefile=%2& shift /1 & shift /1 & goto setOptions)
if [%1[==[-outputfile[ (set outputfile=%2& shift /1 & shift /1 & goto setOptions)
if [%1]==[-debug] (set debug=true& shift /1 & goto setOptions)
if not [%1[==[[ goto promptuser


:: workspace, rulefile, exportdir are mandatory
:validate
if [%workspace%[==[[ (
	echo -workspace parameter is mandatory 
	goto promptuser
)
if [%rulefile%[==[[ (
	echo -rulefile parameter is mandatory 
	goto promptuser
)
if [%exportdir%[==[[ (
	echo -exportdir parameter is mandatory 
	goto promptuser
)


:: construct parameters and command
set ap_parm=-application com.ibm.rsaz.analysis.commandline.AnalyzeApplication
set ws_parm=-data %workspace%
set rf_parm=-rulefile %rulefile%
set exp_parm=-exportdirectory %exportdir%
set dir_parm=
if not [%directory%[==[[ set dir_parm=-directory %directory%
set proj_parm=
if not [%projects%[==[[ set proj_parm=-projects %projects%
set in_parm=
if not [%includefile%[==[[ set in_parm=-includefile %includefile%
set ex_parm=
if not [%excludefile%[==[[ set ex_parm=-excludefile %excludefile%
set command="%rdz_install_dir%\eclipse.exe" %ap_parm% %ws_parm% %rf_parm% %dir_parm% %proj_parm% %in_parm% %ex_parm% %exp_parm% -verbose -nosplash

:: run command
echo Running software analysis...
echo %command%
if not [%outputfile%[==[[ goto commandwithoutput
if [%outputfile%[==[[ goto commandnooutput

:commandwithoutput
%command% > %outputfile%
if [%debug%[==[true[ type %outputfile%
goto done

:commandnooutput
if [%debug%[==[true[ goto commandnooutputdebug
%command%
goto done

:commandnooutputdebug
set outfile=codereviewbatch.log
if not [%tmp%[==[[ set outfile=%tmp%\codereviewbatch.log
%command% > %outfile%
type %outfile%
goto done

:promptuser
echo.   
echo codereviewbatch -workspace ws_location -rulefile rule_file 
echo     -exportdir exp_location [-directory dirs] [-projects projs]
echo     [-includefile in_file] [-excludefile ex_file] [-outputfile out_file]
echo     [-debug]
echo.
echo   ws_location   The workspace location
echo   rule_file     The file containing exported rules to be executed
echo   exp_location  The directory where data files are written
echo   dirs          Comma-separated directories containing source
echo   projs         Comma-separated workspace projects containing source
echo   in_file       File containing list of files to include in analysis      
echo   ex_file       File containing list of files to exclude from analysis
echo   out_file      Target file for command output
echo.   
echo Use -debug to print command output to the console.
echo.   
echo The correct usage of this tool is described in the on-line documentation
echo for Rational Developer for System z. 
goto done

:done
endlocal

Comentarios