JaCoCo configuration for source directory

In the configuration of JaCoCo code coverage section (Ant build step), I can configure:

  • Class file directories
  • Classes to instrument

but not able to configure the source directory and therefore the report does not show the line coverage report.

Looking into my coverage.params file, I can see the property defaulted to "." and I would want to have it "./src":


Looked into the documentation but it does not mention anything on how to configue it. Not found any reported bug on you issue tracker.

TC version used: 9.0.5

Thanks for your help.

Comment actions Permalink

I think you don't need a source directory.
We use it something like this:

for "Classfile directories or jars" %some_project_specific_path%/jar/*.jar
for "Classes to instrument"  com.companyName.*

Comment actions Permalink

Thanks for your reply. Perhaps I wasn't clear enough.

I am able to generate the basic JaCoCo coverage report but ideally I would like to see the link to my source code highlighted, e.g.:


From the JaCoCo documentation:

: Optional container element for Ant resources and     resource collections that specify corresponding source files. If source     files are specified, some report formats include highlighted source code.     Source files can be specified as individual files or as source directories.


It is not a showstopper but would be nice to be able to drill down.

Comment actions Permalink

Do you compile the source code with debugging information? (Attribute "debug" of the ant javac task)

Comment actions Permalink

Hi Marcos,

By default in TeamCity "jacoco.sources" property is set to "." which means that TeamCity will scan whole checkout directory (including all subdirectories - with "src/' in your case) for your sources. So the report should be generated with highlighted source code if coverage is collected properly. Please check that your classfiles are compiled with debug info (including source file info) and check .teamcity/coverage_jacoco/jacoco.log for problems.

You could also try IDEA coverage runner

Comment actions Permalink

Thanks!  Correct answer.

I was not using the debug="on" to compile my classes. Changed it and everything works like a charm now.

Comment actions Permalink

Spasiva Adrey.

>>By default in TeamCity "jacoco.sources" property is  set to "." which means that TeamCity will scan whole checkout directory  (including all subdirectories - with "src/' in your case) for your  sources.
Very thorough answer. I wish this sentece would have been in the TC wiki page when I was having the issue :)  it would have really helped me. Thanks!


Please sign in to leave a comment.