source files in nested subdirectories not showing up on a report (jacoco ant target is used)

788 views
Skip to first unread message

Vicki Kozel

unread,
Jan 10, 2013, 8:25:14 PM1/10/13
to jac...@googlegroups.com
I have this strange problem whith my sources not showing up in the html report created through jacoco ant task.I tried multiple regexes in fileset includes, but none worked. It is strange because the class files have an identical structure of sub-directories, and they are being picked up by the reports just fine. When I use fileset without includes - like this - <fileset dir="C:\mycomp\trunk\progA\src\java"/> everything works. But a fileset with includes fails, but only for sourcefiles.

Here's my ant xml:

<classfiles>           
<fileset dir="C:\mycomp\trunk">
<include name="**/*/build/classes/**/*.class"/>
<exclude name="**/*/ext/**/.class"/>
<exclude name="**/*/tools/**/*.class"/>
</fileset>
 </classfiles>


<sourcefiles encoding="UTF-8">
<fileset dir="C:\mycomp\trunk">
<include name="**/*/src/java/**/*.java"/>
<exclude name="**/*/ext/**/.java"/>
<exclude name="**/*/tools/**/*.java"/>
</fileset>
 </sourcefiles>

Marc R. Hoffmann

unread,
Jan 11, 2013, 1:37:58 AM1/11/13
to jac...@googlegroups.com
Hi,

there is a subtile difference between classfiles and sourcefiles:

* All files provided in the classfiles tag are processed by the analyzer
one by one. The relative location if class files is not evaluated, as
the full qualified class name is retrieved from the class file itself.

* The source files are looked up on a relative position. As JaCoCo is
source language neutral source files are not parsed. The qualified name
is only derived from the relative path and filename. As documentation
says: "Source file resources must always be specified relative to the
respective source folder. If directory resources are given, they must
directly point to source folders. Otherwise source lookup will not succeed."

The proper solution in your case is not to specify a fileset but the set
of source directories:

<sourcefiles encoding="UTF-8">
<dirset dir="C:\mycomp\trunk">
<include name="**/*/src/java"/>
<exclude name="**/*/ext"/>
<exclude name="**/*/tools"/>
</dirset>
</sourcefiles>

Best regards,
-marc
> --
>

Vicki Kozel

unread,
Jan 11, 2013, 1:48:41 PM1/11/13
to jac...@googlegroups.com
Marc, thank you so much for providing a solution to my problem yet again. Your snippet worked perfectly, and I did find the entry about sourcefiles element in the jacoco docs. I think my mistake was in failing to realize that
<include name="**/*/src/java/**/*.java"/>
inside fileset is treated as an absolute path, as opposed to
<include name="**/*/src/java"/>
that is treated as a relative path inside dirset.

Thank you!
Vicki
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages