Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.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

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
Java 转换jacoco.exec错误_Java_Ant_Jacoco - Fatal编程技术网

Java 转换jacoco.exec错误

Java 转换jacoco.exec错误,java,ant,jacoco,Java,Ant,Jacoco,我正在尝试转换/使用我以前生成的jacoco.exec。我使用的是谷歌上的build.xml。在我的目录文件夹中,我的目录文件夹中有以下文件: build.xml CompareNumbers.class jacoco.exec src build.xml~ jacocoant.jar Main.class TestCompareNumbers.class 另外,src文件夹包含我的java类: CompareNumbers.java Main.java

我正在尝试转换/使用我以前生成的jacoco.exec。我使用的是谷歌上的build.xml。在我的目录文件夹中,我的目录文件夹中有以下文件:

    build.xml   CompareNumbers.class  jacoco.exec  src
build.xml~  jacocoant.jar         Main.class   TestCompareNumbers.class
另外,src文件夹包含我的java类:

CompareNumbers.java  Main.java  TestCompareNumbers.java
My build.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<!-- 
   Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors
   All rights reserved. This program and the accompanying materials
   are made available under the terms of the Eclipse Public License v1.0
   which accompanies this distribution, and is available at
   http://www.eclipse.org/legal/epl-v10.html

   Contributors:
      Marc R. Hoffmann - initial API and implementation
-->
<project name="Example Ant Build with JaCoCo" default="rebuild" xmlns:jacoco="antlib:org.jacoco.ant">

    <description>
      Example Ant build file that demonstrates how a JaCoCo coverage report
      can be itegrated into an existing build in three simple steps.
    </description>

    <property name="src.dir" location="./src"/>
    <property name="result.dir" location="./"/>
    <property name="result.classes.dir" location="${result.dir}/classes"/>
    <property name="result.report.dir" location="${result.dir}/site/jacoco"/>
    <property name="result.exec.file" location="${result.dir}/jacoco.exec"/>

    <!-- Step 1: Import JaCoCo Ant tasks -->
    <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
        <classpath path="./jacocoant.jar"/>
    </taskdef>

    <target name="clean">
        <delete dir="${result.dir}"/>
    </target>

    <target name="compile">
        <mkdir dir="${result.classes.dir}"/>
        <javac srcdir="${src.dir}" destdir="${result.classes.dir}" debug="true" includeantruntime="false"/>
    </target>

    <target name="test" depends="compile">
        <!-- Step 2: Wrap test execution with the JaCoCo coverage task -->
        <jacoco:coverage destfile="${result.exec.file}">
            <java classname="org.jacoco.examples.parser.Main" fork="true">
                <classpath path="${result.classes.dir}"/>
                <arg value="2 * 3 + 4"/>
                <arg value="2 + 3 * 4"/>
                <arg value="(2 + 3) * 4"/>
                <arg value="2 * 2 * 2 * 2"/>
                <arg value="1 + 2 + 3 + 4"/>
                <arg value="2 * 3 + 2 * 5"/>
            </java>
        </jacoco:coverage>
    </target>

    <target name="report" depends="test">
        <!-- Step 3: Create coverage report -->
        <jacoco:report>

            <!-- This task needs the collected execution data and ... -->
            <executiondata>
                <file file="${result.exec.file}"/>
            </executiondata>

            <!-- the class files and optional source files ... -->
            <structure name="JaCoCo Ant Example">
                <classfiles>
                    <fileset dir="${result.classes.dir}"/>
                </classfiles>
                <sourcefiles encoding="UTF-8">
                    <fileset dir="${src.dir}"/>
                </sourcefiles>
            </structure>

            <!-- to produce reports in different formats. -->
            <html destdir="${result.report.dir}"/>
            <csv destfile="${result.report.dir}/report.csv"/>
            <xml destfile="${result.report.dir}/report.xml"/>
        </jacoco:report>
    </target>

    <target name="rebuild" depends="clean,compile,test,report"/>

</project>
    /home/luci/workspace/dir/build.xml:26: The following error occurred while executing this line:
jar:file:/usr/share/ant/lib/jacocoant.jar!/org/jacoco/ant/antlib.xml:19: taskdef A class needed by class org.jacoco.ant.ReportTask cannot be found: org/jacoco/core/analysis/ICoverageVisitor
 using the classloader AntClassLoader[/home/luci/workspace/dir/jacocoant.jar]