- jacoco二开,主要加入了增量代码匹配的功能 具体设计方案参考 jacoco增量代码实践
- 新增类:所有新增类处于org.jacoco.core.internal.diff包下面;
- 修改类:主要修改了核心类org.jacoco.core.analysis.Analyzer,org.jacoco.core.analysis.CoverageBuilder;org.jacoco.core.internal.flowClassProbesAdapter
- 所有修改内容在commit记录可查,为了方便查看,我尽量减少了commit的次数
3、 其中org.jacoco.cli-0.8.7-SNAPSHOT-nodeps.jar为构建出的我们需要的包(我已经构建好,懒得编译从这里下载下载地址)
"[{\"classFile\":\"com/dr/code/diff/config/GitConfig\",\"methodInfos\":[{\"methodName\":\"cloneRepository\",\"parameters\":\"String gitUrl,String codePath,String commitId\"},{\"methodName\":\"diffMethods\",\"parameters\":\"DiffMethodParams diffMethodParams\"},{\"methodName\":\"getClassMethods\",\"parameters\":\"String oldClassFile,String mewClassFile,DiffEntry diffEntry\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/code/diff/controller/CodeDiffController\",\"methodInfos\":[{\"methodName\":\"getList\",\"parameters\":\"@ApiParam(required = true, name = \\\"gitUrl\\\", value = \\\"git远程仓库地址\\\") @RequestParam(value = \\\"gitUrl\\\") String gitUrl,@ApiParam(required = true, name = \\\"baseVersion\\\", value = \\\"git原始分支或tag\\\") @RequestParam(value = \\\"baseVersion\\\") String baseVersion,@ApiParam(required = true, name = \\\"nowVersion\\\", value = \\\"git现分支或tag\\\") @RequestParam(value = \\\"nowVersion\\\") String nowVersion\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/code/diff/service/impl/CodeDiffServiceImpl\",\"methodInfos\":[{\"methodName\":\"getDiffCode\",\"parameters\":\"DiffMethodParams diffMethodParams\"}],\"type\":\"MODIFY\"},{\"classFile\":\"com/dr/common/utils/string/ScmStringUtil\",\"methodInfos\":[],\"type\":\"ADD\"}]"
由于对象格式的通用性,可以配合 差异代码获取 一起使用
#近期github不稳定,请访问https://gitee.com/Dray/jacoco.git
java -jar org.jacoco.cli-0.8.7-SNAPSHOT-nodeps.jar report jacoco.exec --classfiles \Desktop\feigin\web\build\classes --classfiles \Desktop\feigin\biz\build\classes --classfiles \Desktop\feigin\base\build\classes --sourcefiles \Desktop\feigin\web\src\main\java --sourcefiles \Desktop\feigin\biz\src\main\java --sourcefiles \Desktop\feigin\base\src\main\java --html report --xml jacoco.xml --diffCode "[{"classFile":"com/dr/code/diff/config/GitConfig","methodInfos":[{"methodName":"cloneRepository","parameters":"String gitUrl,String codePath,String commitId"},{"methodName":"diffMethods","parameters":"DiffMethodParams diffMethodParams"},{"methodName":"getClassMethods","parameters":"String oldClassFile,String mewClassFile,DiffEntry diffEntry"}],"type":"MODIFY"},{"classFile":"com/dr/code/diff/controller/CodeDiffController","methodInfos":[{"methodName":"getList","parameters":"@ApiParam(required = true, name = \"gitUrl\", value = \"git远程仓库地址\") @RequestParam(value = \"gitUrl\") String gitUrl,@ApiParam(required = true, name = \"baseVersion\", value = \"git原始分支或tag\") @RequestParam(value = \"baseVersion\") String baseVersion,@ApiParam(required = true, name = \"nowVersion\", value = \"git现分支或tag\") @RequestParam(value = \"nowVersion\") String nowVersion"}],"type":"MODIFY"},{"classFile":"com/dr/code/diff/service/impl/CodeDiffServiceImpl","methodInfos":[{"methodName":"getDiffCode","parameters":"DiffMethodParams diffMethodParams"}],"type":"MODIFY"},{"classFile":"com/dr/common/utils/string/ScmStringUtil","methodInfos":[],"type":"ADD"}]" --encoding utf8
5、由于差异代码可能变更较大,这里支持了支持传递jsonw文件的方式: 请执行命令时带入参数 --diffCodeFiles /app/diff/change.json 这种方式和字符串方式只能同时支持一种
##github的版本升级至0.8.9,代码分支为master_merge