1.BEAM下载地址: https://w3.eda.ibm.com/beam/install.html
安装beam-3.6.1-install.exe
假设安装目录 C:\Program Files\BEAM-3.6.1
2.安装ActivePerl (如果没有perl解释器)
假设安装目录 C:\Perl
3.切换至目录C:\Perl\bin
输入以下命令:
- perl "c:/Program Files/BEAM-3.6.1/bin/beam_configure"
- --java javac -o my_config.tcl
生成 my_config.tcl
4.切换到项目根目录
将my_config.tcl拷贝到根目录下
新建目录/class/beam,用于存放检测结果
另外还需要两个文件:
1.my_parms.tcl
该文件用于定制规则
- # STEP.1
- # this activate some sensible default settings that is useful
- # it has several levels to choose
- # use beam_level1_parms.tcl for a deeper analysis. It might run a little
- # longer and might produce a few more false complaints but the trade-off
- # is that it has been designed to help find more elusive bugs
- # beam_never_parms.tcl ---a clean set to add on rules
- # beam_always_parms.tcl ---a full set to remove useless rules
- #source beam_default_parms.tcl
- source beam_level1_parms.tcl
- # STEP.2
- # here, use disabled_files to tell BEAM which files to ignore
- # like this:
- # set beam::disabled_files { */foo/* }(ignore all files in directory foo)
- # STEP.3
- # here ,choose which complaints to activate an which to disable
- # like this:
- # set beam::ERROR1::enabling_policy "always" (enabled)
- # set beam::ERROR3::enabling_policy "" (disabled)
- # STEP.4
- # here, wo add other tcl files to turn on some checks
- # like this:
- source beam_security.tcl
- # it turns the security check on
- # STEP.5
- # here,set the max time that BEAM check 1000 lines of code
- # like this:
- # set beam::max_time_per_kloc_in_sec "300"
- # it sets the time 300 secs. the default time is 600.
2.build.xml
该文件用于集成到ant
- <?xml version="1.0"?>
- <project name="commerce" default="usage" basedir=".">
- <property name="beam.install" value="C:/Program Files/BEAM-3.6.1"/>
- <property name="code.dir" value="./com/ibm/commerce"/>
- <path id="classpath">
- <fileset dir="./lib">
- <include name="**/*.jar"/>
- </fileset>
- </path>
- <taskdef name="beam"
- classname="com.ibm.beam.ant.BeamTask"
- classpath="${beam.install}/jar/ant-beam.jar" />
- <target name="beam" description="runs all code through beam.">
- <beam srcdir="${code.dir}" source="1.6" destdir="./class/beam">
- <classpath refid="classpath"/>
- <option>--beam::compiler=my_config.tcl</option>
- <option>--bean::parms=my_parms.tcl</option>
- <option>--beam::parser_file=./class/beam/BEAM-parseErrors</option>
- <option>--beam::root=./class/beam</option>
- <option>--beam::data=./class/beam/beam_data</option>
- <option>--beam::display_analyzed_files</option>
- <option>--beam::complaint_file=./class/beam/BEAM-messages</option>
- <option>--beam::stats_file=./class/beam/BEAM-functions</option>
- </beam>
- </target>
- </project>
5.切换到项目根目录,输入以下命令
ant beam