Cobertura ant 脚本缺少 Log4J 类 [英] Cobertura ant script is missing Log4J classes
问题描述
我试图让 Cobertura 在我的 ant 脚本中运行,但我在开始时被卡住了.当我尝试插入 cobertura taskdef 时,我缺少 Log4J 库.
I tried to get Cobertura running inside my ant script, but I'm stuck right at the beginning. When I try to insert the cobertura taskdef I'm missing the Log4J libraries.
<property name="cobertura.dir" location="/full/path/to/cobertura-1.9.3" />
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
我的蚂蚁目标
<!-- =================================
target: cobertura
================================= -->
<target name="cobertura" depends="clean, init" description="Generates cobertura coverage reports">
<cobertura-instrument todir="${dir.build.instrumented}">
<fileset dir="${dir.build}">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
</target>
我想我所做的一切都与 Cobertura 文档 中描述的一样,但我明白了
I think I did everything like it is described in the Cobertura documentation but I get this
BUILD FAILED
build.xml:95: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
在 ${cobertura.dir} 内有包含所有文件的 lib 目录.我将它从 cobertura 发行版 ZIP 中直接解压到该目录中.
Inside the ${cobertura.dir} there is the lib directory with all files. I unzipped it from the cobertura distribution ZIP directly into that directory.
我错过了一步吗?到目前为止我的配置有问题吗?
Am I missing a step? Something wrong with my configuration so far?
推荐答案
我今天也遇到了这个问题,并通过指定所有必需库的位置作为提供给我的 taskDef 任务的类路径的一部分来解决它.
I also encountered this problem today and solved it by specifying the location of all the required libraries as part of the class path provided to my taskDef task.
<path id="cobertura.class.path">
<pathelement location="${common.dir}/../tools/cobertura/cobertura.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/asm-3.0.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/asm-tree-3.0.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/log4j-1.2.9.jar" />
<pathelement location="${common.dir}/../tools/cobertura/lib/jakarta-oro-2.0.8.jar" />
</path>
<taskdef classpathref="cobertura.class.path" resource="tasks.properties" />
这篇关于Cobertura ant 脚本缺少 Log4J 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!