Coveralls is web service created by LEMUR Heavy that helps tracking code coverage over time. Coveralls is free to use for open source projects and it requires that the projects are hosted at GitHub. The service was originally created for Ruby projects, but the provided API allows anybody to create code coverage report clients. Numerous integrations have been created for different languages such as Python, PHP, Node.js and Scala by the open source community, but there was no support for Java projects. I find this odd, because in the enterprise Java world such metrics are everyday life. There are plenty of different coverage tools and metrics platforms available like Cobertura, JaCoCo, SonarQube (previously known as Sonar) and so on.

Coveralls integrates nicely with Travis CI, which is a continuous integration service for GitHub hosted projects. Travis CI is also free to use for open source projects. GitHub, Travis CI and Coveralls now provide a good continuous integration platform for open source projects. A lot of languages are already supported by these tools and GitLab is a nice example of a widely used open source project using the services. Java ecosystem is poorly supported even though it is backed by a large open source community.

I have created coveralls-maven-plugin that can be used to provide coverage reports to Coveralls web service. The plugin also integrates nicely with Travis CI, so that every build run by Travis CI will be reported to Coveralls. This means good tracking of code coverage over time for your projects. The coverage maven plugins can also be configured to fail builds for too low code coverage on unit tests.

Here’s some of the plugin highlights:

  • 1.1.0 version supports Cobertura and JaCoCo coverage Maven plugins.
  • Fully streaming implementation for fast report generation and small memory footprint. This is good for big projects that could consume the limited resources of Travis CI.
  • Contributing to the plugin is fairly easy. Code is clean and has simple interfaces to provide support for additional coverage tools and continuous integration services.
  • The plugin is easy to setup. Setting one configuration value is sufficient for most use cases.
  • The project is licensed under the MIT license.

Full documentation is available at GitHub and for reference jersey-mustache project is using the plugin with Travis CI and Coveralls integrations.

Posted in Java | Tagged , , ,
Share this post, let the world know


  1. Tapio Rautonen
    Posted 2013/07/02 at 23:01 | Permalink

    Version 1.2.0 of the coveralls-maven-plugin released with the following changes:
    + Coverage metrics recorded and logged in the execution of the goal
    + Build timestamp added and sent to Coveralls
    + Validation of the Job to fail fast on configuration issues

  2. Tapio Rautonen
    Posted 2013/07/30 at 11:05 | Permalink

    Version 2.0.0 of the coveralls-maven-plugin released with the following changes:
    + Built-in support for Travis, Circle, Codeship, Jenkins and Bamboo continuous integration services
    + Multi-module report aggregation with Cobertura
    + Support for multiple source directories
    + Dry run property for test builds

  3. Posted 2014/01/05 at 21:08 | Permalink

    Many thanks for writing this great Maven plugin for Coveralls. It worked for me with no problems. Bravo!

  4. feynman
    Posted 2014/03/05 at 01:54 | Permalink

    Hi there,

    I have a project with an ant based build system, which uses jacoco to generate coverage reports. I’ve been wondering about using your plugin to push them to coveralls. Obviously your plugin wouldnt work with ant without some serious effort, however it seems like I should be able to do the following in a travis script:
    1) Generate the jacoco xml report file in an ant script
    2) Submit the file to coveralls using a very minimal mvn script.
    Does this seem like it should be posible with your mvn plugin?

    Additionally I have a multi-project build, such that multiple jacoco xml reports are generated (for modules in the same repo), is there a way to chain these together with your plugin?


  5. Posted 2014/03/06 at 00:33 | Permalink

    Good job Tapio! Thank you for creating this great plugin. I just started using it on the Tr8n Java SDK. Took me about 5 minutes to get it all setup and running.

    I’ve also added a few lines of Ruby code and a shell script to create a source code monitor that builds code and generate reports every time I save files. On a mac it will also show a notification message for me once the build is complete.

  6. Tapio Rautonen
    Posted 2014/03/06 at 07:53 | Permalink

    @feynman I think the suggested approach is fully doable with the coveralls maven plugin. You can run the coveralls:jacoco goal independently and just configure the ‘coverallsFile’ property to point to the location of your ant built jacoco report file. The coveralls goal does not trigger any other maven lifecycle goals so it should not require the basic maven project structure or anything else.

    Currently my plugin does not support aggregation of reports from same coverage tool. I have a version 3 roadmap in my head and this is a feature that will most likely get in there when I get the time to implement. This way more tools that do not support multi module aggregation can be used with the plugin. Also the chaining of different coverage tools to a single aggregate report will be the default configuration approach in the later versions.

    If you have any issues, feel free to post to the github issues section of the project.

  7. Tapio Rautonen
    Posted 2014/03/06 at 07:58 | Permalink

    @michael Nice to hear! I tried to make the plugin as simple as it gets to adopt in projects build with Travis CI.

    The script you have is fine for small projects, but when the project gets bigger, it probably has thousands or tens of thousands of unit tests, it will proably kill totally your dev machine when the unit tests are triggered on file save. I personally run the relevant tests straight from IDE and let the CI do the rest.

  8. Vinicius da Costa Pires
    Posted 2015/02/04 at 04:14 | Permalink

    Tapio, thanks for the great plugin & blog post.

    How did you manage to extract the repoToken from the code? Coveralls asks to remove from the repository but it is never clear about the alternative…

    Thanks in advance.

  9. Jakub Narloch
    Posted 2015/08/12 at 21:11 | Permalink

    Any plans on gradle plugin in future?

  10. Tapio Rautonen
    Posted 2015/08/16 at 23:21 | Permalink

    At the moment only Travis CI supports automatic job detection, which means you can leave out the whole repository token. So if you are building with Travis CI, just leave out the token and the plugin, Travis CI and Coveralls automatically handle it.

    If you have private repository and a private CI, then adding the token in pom.xml is not much of a problem, but for public CI’s and public repositories, you should use the CI’s encryption mechanics or project based secret vars, or whatever is possible. So keep your token secret and resolve it through an environment variable to the pom.xml or via command line argument.

  11. Tapio Rautonen
    Posted 2015/08/16 at 23:36 | Permalink

    @Jakub, sorry no plans for gradle plugin. I have so few gradle projects and so limited time to work on these open source projects, so it’s not possible.

    There’s a gradle plugin which might help you.

Leave a Reply

Your email address will not be published. Required fields are marked *