What is the pattern used in <jacoco: coverage /> s "excludes" attribute.

5,349 views
Skip to first unread message

Asanke Galgomuwa

unread,
Aug 15, 2016, 1:49:49 AM8/15/16
to JaCoCo and EclEmma Users
The doc in http://www.eclemma.org/jacoco/trunk/doc/ant.html says

excludesA list of class names that should be excluded from execution analysis. The list entries are separated by a colon (:) and may use wildcard characters (* and ?). Except for performance optimization or technical corner cases this option is normally not required.empty (no excluded classes)

I have a ant build which executes the jacoco  with junit task

I have configured my ant buld as follows;

<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpathref="jacoco.classpath" />
<jacoco:coverage destfile="${jacoco.dir}/jacoco.exec" append="false" xmlns:jacoco="antlib:org.jacoco.ant" excludes="**/*AppIdentifier*.*">
      <junit fork="yes" forkmode="once" printsummary="true" failureproperty="junit.failure" haltonfailure="no" showoutput="true">
                       .
                       .
                       .
             </junit>
       </jacoco:coverage>

I need to exclude one application class (Why is a long story), (say AppIdentifier.class) from the code coverage  so that this do not gets instrumented with jacoco. I bliev that means the class should not be in jacoco.exec when the test finishes.

 I have used the following patterns to try to figure out the way the exclusion works.

excludes="*"  - that exclude all classes
excludes="*.class"  - that include all classes
excludes="**/*.class" - that include all classes
excludes="**/*.*" - that exclude all classes

So hoping the result will be a success I used ...
excludes=**/*AppIdentifier*.* - includes all

So non  of this works for me.
How can I exclude the the give AppIdentifier.class from my coverage.


I use Jnuit 4.12
java 1.6
jacoco 0.7.6.201602180812

Marc Hoffmann

unread,
Aug 15, 2016, 3:00:29 AM8/15/16
to jac...@googlegroups.com
Hi,

the name is the the JVM class name, e.g. org/example/AppIdentifier (no
.class suffix).

So actually excludes="*AppIdentifier*" should do the job.

Regards,
-marc

On 2016-08-15 07:49, Asanke Galgomuwa wrote:
> The doc in http://www.eclemma.org/jacoco/trunk/doc/ant.html says
>
> excludes
> A list of class names that should be excluded from execution
> analysis. The list entries are separated by a colon (:) and may use
> wildcard characters (* and ?). Except for performance optimization or
> technical corner cases this option is normally not required.
> _empty_ (no excluded classes)
>
> I have a ant build which executes the jacoco with junit task
>
> I have configured my ant buld as follows;
>
> <TASKDEF URI="ANTLIB:ORG.JACOCO.ANT"
> RESOURCE="ORG/JACOCO/ANT/ANTLIB.XML" CLASSPATHREF="JACOCO.CLASSPATH"
> />
>
> <JACOCO:COVERAGE DESTFILE="${JACOCO.DIR}/JACOCO.EXEC" APPEND="FALSE"
> XMLNS:JACOCO="ANTLIB:ORG.JACOCO.ANT" EXCLUDES="**/*APPIDENTIFIER*.*">
> <JUNIT FORK="YES" FORKMODE="ONCE" PRINTSUMMARY="TRUE"
> FAILUREPROPERTY="JUNIT.FAILURE" HALTONFAILURE="NO" SHOWOUTPUT="TRUE">
> .
> .
> .
> </junit>
>
> </JACOCO:COVERAGE>
>
> I need to exclude one application class (Why is a long story), (say
> AppIdentifier.class) from the code coverage so that this do not gets
> instrumented with jacoco. I bliev that means the class should not be
> in jacoco.exec when the test finishes.
>
> I have used the following patterns to try to figure out the way the
> exclusion works.
>
> EXCLUDES="*" - that EXCLUDE all classes
> EXCLUDES="*.CLASS" - that include all classes
> EXCLUDES="**/*.CLASS" - that include all classes
> EXCLUDES="**/*.*" - that EXCLUDE all classes
>
> So hoping the result will be a success I used ...
> EXCLUDES=**/*APPIDENTIFIER*.* - INCLUDES ALL
>
> So non of this works for me.
> How can I exclude the the give AppIdentifier.class from my coverage.
>
> I use Jnuit 4.12
> java 1.6
> jacoco 0.7.6.201602180812
>
> --
> 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/a9649514-a7c2-483e-93c9-ca0a5582e9a5%40googlegroups.com
> [1].
> For more options, visit https://groups.google.com/d/optout.
>
>
> Links:
> ------
> [1]
> https://groups.google.com/d/msgid/jacoco/a9649514-a7c2-483e-93c9-ca0a5582e9a5%40googlegroups.com?utm_medium=email&utm_source=footer

Asanke Galgomuwa

unread,
Aug 15, 2016, 3:20:37 AM8/15/16
to JaCoCo and EclEmma Users
Hi Marc,
Thanks for the reply.

It worked!!

Regards
Asanke
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages