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
输入以下命令:
 

  1. perl "c:/Program Files/BEAM-3.6.1/bin/beam_configure"   
  2. --java javac -o my_config.tcl 


生成 my_config.tcl
 
4.切换到项目根目录
将my_config.tcl拷贝到根目录下
新建目录/class/beam,用于存放检测结果
另外还需要两个文件:
1.my_parms.tcl
该文件用于定制规则

 

  1. # STEP.1  
  2. # this activate some sensible default settings that is useful  
  3. # it has several levels to choose  
  4. # use beam_level1_parms.tcl for a deeper analysis. It might run a little  
  5. # longer and might produce a few more false complaints but the trade-off   
  6. # is that it has been designed to help find more elusive bugs  
  7. # beam_never_parms.tcl  ---a clean set to add on rules  
  8. # beam_always_parms.tcl ---a full set to remove useless rules  
  9.  
  10. #source beam_default_parms.tcl  
  11. source beam_level1_parms.tcl  
  12.  
  13. # STEP.2  
  14. # here, use disabled_files to tell BEAM which files to ignore  
  15. # like this:  
  16. # set beam::disabled_files { */foo/* }(ignore all files in directory foo)  
  17.  
  18.  
  19. # STEP.3  
  20. # here ,choose which complaints to activate an which to disable  
  21. # like this:  
  22. # set beam::ERROR1::enabling_policy "always"    (enabled)  
  23. # set beam::ERROR3::enabling_policy ""      (disabled)  
  24.  
  25.  
  26.  
  27. # STEP.4  
  28. # here, wo add other tcl files to turn on some checks  
  29. # like this:  
  30. source beam_security.tcl  
  31. # it turns the security check on  
  32.  
  33.  
  34. # STEP.5  
  35. # here,set the max time that BEAM check 1000 lines of code  
  36. # like this:  
  37. # set beam::max_time_per_kloc_in_sec "300"  
  38. # it sets the time 300 secs. the default time is 600.  
  39.  
  40.  

2.build.xml
该文件用于集成到ant

 

  1. <?xml version="1.0"?> 
  2. <project name="commerce" default="usage" basedir="."> 
  3. <property name="beam.install" value="C:/Program Files/BEAM-3.6.1"/>   
  4. <property name="code.dir"  value="./com/ibm/commerce"/>   
  5. <path id="classpath">   
  6.     <fileset dir="./lib">   
  7.         <include name="**/*.jar"/>   
  8.     </fileset> 
  9. </path>   
  10. <taskdef name="beam"   
  11.      classname="com.ibm.beam.ant.BeamTask"   
  12.      classpath="${beam.install}/jar/ant-beam.jar" />   
  13. <target name="beam" description="runs all code through beam.">   
  14.            <beam srcdir="${code.dir}" source="1.6" destdir="./class/beam">   
  15.                     <classpath refid="classpath"/>   
  16.                 <option>--beam::compiler=my_config.tcl</option>    
  17.                 <option>--bean::parms=my_parms.tcl</option>            
  18.                 <option>--beam::parser_file=./class/beam/BEAM-parseErrors</option>   
  19.                 <option>--beam::root=./class/beam</option>   
  20.                 <option>--beam::data=./class/beam/beam_data</option>   
  21.                 <option>--beam::display_analyzed_files</option>   
  22.                 <option>--beam::complaint_file=./class/beam/BEAM-messages</option>   
  23.                 <option>--beam::stats_file=./class/beam/BEAM-functions</option>   
  24.             
  25.            </beam>   
  26. </target>   
  27. </project> 


5.切换到项目根目录,输入以下命令
ant beam


More: https://w3.eda.ibm.com/beam/