Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant 如何将.jar中的类包含在Jacoco覆盖率报告中?_Ant_Jacoco - Fatal编程技术网

Ant 如何将.jar中的类包含在Jacoco覆盖率报告中?

Ant 如何将.jar中的类包含在Jacoco覆盖率报告中?,ant,jacoco,Ant,Jacoco,我有一个ant脚本,它构建、运行JUnit测试、创建报告并创建关于特定包中的两个选定类的覆盖率报告。现在,我创建了一个library.jar,其中包含我希望在覆盖率报告中关注的类。我知道如何在给定包等的覆盖率报告中包括哪些特定文件,如何在.jar文件中为类执行此操作?覆盖范围的当前ant任务: <target name="report" depends="junit"> <jacoco:report xmlns:jacoco="antlib:org.jacoco.ant

我有一个ant脚本,它构建、运行JUnit测试、创建报告并创建关于特定包中的两个选定类的覆盖率报告。现在,我创建了一个library.jar,其中包含我希望在覆盖率报告中关注的类。我知道如何在给定包等的覆盖率报告中包括哪些特定文件,如何在.jar文件中为类执行此操作?覆盖范围的当前ant任务:

<target name="report" depends="junit">
    <jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">                     
        <executiondata>
            <file file="JacocoFile"/>
        </executiondata>                       
         <structure name="Example Project">
           <classfiles>
                   <!-- Right now, everything is in the extotest package -->
            <fileset dir="${build.dir}/extotest"> 
                    <include name="*.class"/>    
            </fileset>
           </classfiles>
           <sourcefiles encoding="UTF-8">
             <fileset dir="${src.dir}/extotest">
             </fileset>
             <fileset dir="${src.dir}/test">
             </fileset>
           </sourcefiles>
         </structure>

        <html destdir="${coverage}/webcoverage"/>
        <xml destfile="${coverage}/coverage.xml" /> 

    </jacoco:report>
   </target>

再见

将jar文件复制到ant任务中给定的目录路径。 Jacoco ant任务将负责。 我也尝试过同样的方法,并从中获得了成功

祝你好运。

添加

<fileset dir="${build.dir}/extotest"> 
      <include name="*.class"/>    
      <include name="*.jar"/> 
</fileset>

在ANT脚本中,将jar文件添加到类路径。

如果需要为覆盖率报告向类文件添加jar文件,而不是为fileset标记提供dir属性,则必须提供file属性

而不是使用

<fileset dir="${build.dir}/extotest">   
      <include name="*.jar"/> 
</fileset>
如上述答案所述,使用

<fileset file="${build.dir}/extotest/*.jar" /> 

检查添加jar文件时这是否解决了问题。。Jacoco在生成报告时抛出错误。