Cobertura乐器战争

时间:2014-03-10 16:29:30

标签: java maven ant cobertura

我正试图用Cobertura 1.9.4.1进行战争。为此,我使用以下ant任务,该任务使用maven-antrun-plugin调用:

<target name="instrumentEar">
    <cobertura-instrument todir="${module}/target/${ear.dir}">
        <includeclasses regex="nl.*" />
        <fileset dir="${module}/target/${ear.dir}">
            <include name="**/*.war"/>
        </fileset>
    </cobertura-instrument>
</target>

执行时输出为:

[INFO] --- maven-antrun-plugin:1.3:run (instrument) @ my-ear ---
[INFO] Executing tasks

instrumentEar:

[cobertura-instrument] Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura-instrument] Instrumenting 2 files to D:\workspace\my-ear\target\my-ear-1.0.0-SNAPSHOT
[cobertura-instrument] Cobertura: Error closing output stream.
[cobertura-instrument] java.util.zip.ZipException: ZIP file must have at least one entry
[cobertura-instrument]  at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:304)
[cobertura-instrument]  at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:146)
[cobertura-instrument]  at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:321)
[cobertura-instrument]  at net.sourceforge.cobertura.util.IOUtil.closeOutputStream(IOUtil.java:165)
[cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentationToArchive(Main.java:319)
[cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:488)
[cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.main(Main.java:514)
[cobertura-instrument] Cobertura: Error closing output stream.
[cobertura-instrument] java.util.zip.ZipException: ZIP file must have at least one entry
[cobertura-instrument]  at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:304)
[cobertura-instrument]  at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:146)
[cobertura-instrument]  at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:321)
[cobertura-instrument]  at net.sourceforge.cobertura.util.IOUtil.closeOutputStream(IOUtil.java:165)
[cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.addInstrumentationToArchive(Main.java:319)
[cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:488)
[cobertura-instrument]  at net.sourceforge.cobertura.instrument.Main.main(Main.java:514)
[cobertura-instrument] Cobertura: Saved information on 0 classes.
[cobertura-instrument] Instrument time: 67ms

似乎蚂蚁无法阅读maven创造的战争。我记得很久以前我遇到过java zip实现的问题并使用了ant中的一个。这可能是类似的事情发生在这里,但逆转了吗?

This thread表明这应该有效,但有些人建议在检测前先提取战争。

是否有任何人在蚂蚁任务(cobertura-instrument)上取得任何成功来应对战争?

1 个答案:

答案 0 :(得分:0)

我通过分别从WAR中包含的不同项目中检测类文件,然后将它们合并到应用程序服务器启动的目录来解决这个问题。

我已经检测了各个项目以获得每个项目的覆盖率,因此合并操作实际上只需要添加。

因此无需检测WAR。