excluding the intersect of two 'excludes'

34 views
Skip to first unread message

lvhu...@gmail.com

unread,
Oct 31, 2019, 5:23:33 AM10/31/19
to JaCoCo and EclEmma Users
Hi,

How can I intersect two 'excludes' when defining 'fileset' for ant's report target?

My situation is, I'm running api test and unit test for the same code. Each test has its own 'exclude' files. Now I want to merge the two jacoco report together, and my steps are:

1. merge the .exec files dumped by these two tests. This is easy.
2. use 'ant ... report' to generate the report. So, I need to intersect the two 'exclude' sets -- that is, classes excluded by both tests will be excluded; classes excluded by only one of these tests (i.e., not excluded by the other test) shouldn't be excluded.

I searched and tried the following approaches:

1. as follows, but ant complains "intersect doesn't support the nested "patternset" element."
<patternset id='id1'>
    <exclude name=.../>
    <exclude name=.../>
</patternset>
<patternset id='id2'>
    <exclude name=.../>
    <exclude name=.../>
</patternset>
<intersect id='id3'>
    <patternset refid='id1'/>
    <patternset refid='id2'/>
</intersect>

2. as follows, but ant complains "resources doesn't support the nested "exclude" element."
<resources id='id1'>
    <exclude name=.../>
    <exclude name=.../>
</resources>
<resources id='id2'>
    <exclude name=.../>
    <exclude name=.../>
</resources>
<intersect id='id3'>
    <resources refid='id1'/>
    <resources refid='id2'/>
</intersect>
...
<classfiles>
    <fileset dir="...">
        <resources refid='excludes'/>
    </fileset>
</classfiles>

3. as follows, but ant complains "fileset doesn't support the nested "resources" element"
<patternset id='id1'>
    <exclude name=.../>
    <exclude name=.../>
</patternset>
<patternset id='id2'>
    <exclude name=.../>
    <exclude name=.../>
</patternset>
<intersect id='id3'>
    <resources refid='id1'/>
    <resources refid='id2'/>
</intersect>
...
<classfiles>
    <fileset dir="...">
        <resources refid='excludes'/>
    </fileset>
</classfiles>
    
So what's the correct way to do this? I'm not familiar with the resource collections, so any help will be highly appreciated.

Thanks!
--huafeng

Marc Hoffmann

unread,
Oct 31, 2019, 1:22:50 PM10/31/19
to jac...@googlegroups.com
Hi,

while I have to admit that I don’t understand your use case I think this can be solved by providing two file sets:

<classfiles>
  <fileset excludes=“pattern1”/>
  <fileset excludes=“pattern2”/>
</classfiles>

The classfiles tag internally is implemented as a Union. So you can add multiple resource specifications. So in the end you get all classfiles which are not excluded in both sets.

Regards,
-marc

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/1f97b34f-aa72-451a-a3ce-23ed5be8382d%40googlegroups.com.

lvhu...@gmail.com

unread,
Nov 6, 2019, 9:19:46 AM11/6/19
to JaCoCo and EclEmma Users
That works! Thanks a lot, Marc!
--huafeng
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages