如何使用 Ant 从 Jacoco 报告中分组 类

How to group classes from Jacoco report using Ant

我正在使用 Jacoco 和 Ant 从几个模块中为 类 生成代码覆盖率报告。

源目录/

蚂蚁任务: ...

<property name="src.dir" location="sourceDir"/>

<target name="report">
    <jacoco:report>

        <executiondata>
            <file file="${result.exec.file}" />
        </executiondata>

        <structure name="JaCoCo Report">
            <classfiles>
                <fileset dir="${src.dir}" includes="**/target/classes/**" />
            </classfiles>
            <sourcefiles encoding="UTF-8">
                <fileset dir="${src.dir}" />
            </sourcefiles>
        </structure>

        <html destdir="${result.report.dir}" />
        <csv destfile="${result.report.dir}/report.csv" />
        <xml destfile="${result.report.dir}/report.xml" />
    </jacoco:report>
</target>

运行 Ant 任务 我得到类似这样的报告:

举报

想要这样的东西:

报告:

http://www.jacoco.org/jacoco/trunk/doc/ant.html 引用文档:

The structure can be refined with a hierarchy of group elements. This way the coverage report can reflect different modules of a software project. For each group element the corresponding class and source files can be specified separately. For example:

<structure name="Example Project">
    <group name="Server">
        <classfiles>
            <fileset dir="${workspace.dir}/org.jacoco.example.server/classes"/>
        </classfiles>
        <sourcefiles>
            <fileset dir="${workspace.dir}/org.jacoco.example.server/src"/>
        </sourcefiles>
    </group>
    <group name="Client">
        <classfiles>
            <fileset dir="${workspace.dir}/org.jacoco.example.client/classes"/>
        </classfiles>
        <sourcefiles>
            <fileset dir="${workspace.dir}/org.jacoco.example.client/src"/>
        </sourcefiles>
    </group>
    ...
</structure>