As in most cases my class files are at 2 locations inside tomcat at, lib
and classes
. Now once .exec
file is created I need to pull a report referencing both the locations classes
and a few jars in lib
, for this I am using the below command
java -jar jacococli.jar report /local/jacoco.exec --html /jacocoReport/html --name MergeCode --classfiles /tomcat/webapps/<app>/WEB-INF/lib/new.jar /tomcat/webapps/<app>/WEB-INF/classes
but it is throwing error, and from the error it looks like it is considering the second location/jar from --classfiles
option as an exec file.
[INFO] Loading execution data file /local/jacoco.exec.
[INFO] Loading execution data file /tomcat/webapps/<app>/WEB-INF/classes.
Exception in thread "main" java.io.FileNotFoundException: /tomcat/webapps/<app>/WEB-INF/classes (Is a directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:71)
at org.jacoco.cli.internal.commands.Report.loadExecutionData(Report.java:98)
at org.jacoco.cli.internal.commands.Report.execute(Report.java:82)
at org.jacoco.cli.internal.Main.execute(Main.java:89)
at org.jacoco.cli.internal.Main.main(Main.java:104)
I have tried moving classes before the jar file, the exception is different
[INFO] Loading execution data file /local/jacoco.exec.
[INFO] Loading execution data file /tomcat/webapps/<app>/WEB-INF/lib/new.jar.
Exception in thread "main" java.io.IOException: Invalid execution data file.
at org.jacoco.cli.internal.core.data.ExecutionDataReader.read(ExecutionDataReader.java:89)
at org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:59)
at org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:73)
at org.jacoco.cli.internal.commands.Report.loadExecutionData(Report.java:98)
at org.jacoco.cli.internal.commands.Report.execute(Report.java:82)
at org.jacoco.cli.internal.Main.execute(Main.java:89)
at org.jacoco.cli.internal.Main.main(Main.java:104)
for
java -jar jacococli.jar classinfo /tomcat/webapps/<app>/WEB-INF/lib/new.jar /tomcat/webapps/<app>/WEB-INF/classes /tomcat/webapps/<app>/WEB-INF/lib/new1.jar
multiple files work fine all classes in the classes
folder and set of jar files in lib
folder are listed,
Documentation at http://www.jacoco.org/jacoco/trunk/doc/cli.html states that --classfiles
for report can have multiple files but does not state example or delimiter. I tried with comma, semicolon but it does not work ' '[space] works with classinfo so I am assuming it should work with report also.
Googling also did not result in any examples for jacococli.jar.
答案 0 :(得分:2)
http://www.jacoco.org/jacoco/trunk/doc/cli.html处的文档指出 - 报表的类文件可以包含多个文件
这是错误的 - http://www.jacoco.org/jacoco/trunk/doc/cli.html处的文档实际上说明了
可以多次指定一些参数以提供多个值。
和
--classfiles <path>
可以按字面指定多次,即
--classfiles path1 --classfiles path2
当您省略前缀--classfiles
时,它将被解释为
<execfiles>
给出例外
Exception in thread "main" java.io.FileNotFoundException: /tomcat/webapps/<app>/WEB-INF/classes (Is a directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.<init>(FileInputStream.java:138) at org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:71)
和
Exception in thread "main" java.io.IOException: Invalid execution data file. at org.jacoco.cli.internal.core.data.ExecutionDataReader.read(ExecutionDataReader.java:89) at org.jacoco.cli.internal.core.tools.ExecFileLoader.load(ExecFileLoader.java:59)
如预期的那样 - 在一种情况下它不是文件而在另一种情况下它不是有效的exec文件。
&#39; &#39; [space]与classinfo一起工作,所以我假设它也应该与报告一起使用
report
和classinfo
是两个不同的命令,并且具有不同的参数以及所有后果。空间与classinfo
命令一起使用,因为它允许多种规范
<classlocations>
请注意,与report
命令相比,无需指定前缀。