前一篇的链接http://blog.csdn.net/b081221045/article/details/8244889
<?xml version="1.0" encoding="UTF-8"?>
<project name="测试脚本" default="run" basedir="." >
<!--设置重要属性-->
<property name="workdir" value="resource" />
<property name="bytecode.dir" value="${workdir}/code" />
<property name="soot.classpath" value="soot-2.5.0.jar;Scan-soot.jar;${bytecode.dir}" />
<property name="aspectj.fromdir" value="aspectjGen" />
<property name="aspectj.todir" value="${workdir}/monitor" />
<property name="ajc.classpath" value=""%ASPECTJ_HOME%"/lib/aspectjrt.jar;${aspectj.todir}/deadlock-rt.jar " />
<property name="ajc.outputdir" value="run" />
<!-- -->
<target name="scan">
<echo message="${bytecode.dir}" />
<echo message="正在扫描JAVA文件..." />
<exec executable="cmd" failοnerrοr="true">
<arg value="/c java -Dsrc.dir=${bytecode.dir} -cp ${soot.classpath} com.wander.soot.deadlock.Program" />
</exec>
</target>
<target name="compileAJ" depends="scan">
<echo message="正在编译AJ文件..." />
<exec executable="cmd" failοnerrοr="true">
<arg value="/c ajc -classpath ${ajc.classpath} -sourceroots ${aspectj.fromdir} -d ${aspectj.todir}" />
</exec>
<echo message="正在插入代码..."/>
<exec executable="cmd" failοnerrοr="true">
<arg value="/c ajc -classpath ${ajc.classpath} -inpath ${bytecode.dir} -aspectpath ${aspectj.todir} -d ${ajc.outputdir} -source 1.5" />
</exec>
</target>
<target name="moveAJ" depends="compileAJ">
<echo message="正在拷贝Aspectj文件..." />
<copy todir="${ajc.outputdir}" failοnerrοr="true">
<fileset dir="${aspectj.todir}">
<exclude name="*.jar"/>
</fileset>
</copy>
</target>
<target name="run" depends="moveAJ">
<exec executable="showMainClass.bat" failοnerrοr="true">
</exec>
<input message="请输入运行的主类(下标从0开始)"
addproperty="run.index"
/>
<exec executable="runMainClass.bat" failοnerrοr="true">
<arg value="${run.index};${ajc.outputdir}" />
</exec>
</target>
</project>
比起上一个版本,增加了属性标签和aspectj运行的命令参数的不同(底层实现上用Soot代替了AST)