Skip to content

Coveralls.io configuration for maven projects

abelsromero edited this page Dec 28, 2014 · 2 revisions

This page describes the proces to configure and review the Coveralls.io configuration for asciidoctor-maven-plugin, however, this information can be applied to other maven projects using coveralls.io.

Coverall’s data is updated on completion of TravisCI's builds using the maven tool coveralls-maven-plugin [1]. To get that it is required to configure Coveralls.io services as well as TravisCI’s, and adapt the source’s project.

Coveralls/Travis configurations

In order to enable coverage data to be collected follow this steps:

  1. Enable access to organization repositories: after login with GitHub credentials, Coveralls.io only offers access to personal repositories. To enable access to organization one must enable it in the "Pro sign up" section. Once it has been done, the organization will appear in the same "Pro sign up" section.

    Don’t worry about the pro word, it’s still free for public open source repos ;)

  2. Activate repository coverage: from the main panel go to "Repos" and press the "Add Repos" button. There, one should see the whole list of available repositories (owned and organization). Set the On/Off slider to the On position to activate it and then go to "Details". Once in Details, copy the repo key id, it will be later required for TravisCI.

    Note: enable admin access to organization repositories in GitHub: to be able to configure the repo key in Travis one must have admin permissions. For the maven case, it means being included in the asciidoctor’s maven-plugin group.

  3. Configure Coveralls' repo key in TravisCI: access to TravisCI and go to the "Add New Repository" section (currently, a cross on the left panel). If you don’t see the organization here, review the previous step, if you see it:

    1. Select the organization and then activate the project using the On/Off slider.

    2. Go to "Repository settings" (wrench icon) and press the "Environment Variables" option. Then, create a new variable named repoToken using the repo key obtained from Coveralls as value.

This completes the first (and complicated) part of the configuration. 👍

Project configurations

To send the actual coverage data from Travis builds just follow the steps described on https://github.com/trautonen/coveralls-maven-plugin. Just note that the build process is separated to avoid executing tests more than once (see the Travis config in the summary). In the case of asciidoctor-maven-plugin, the Jacoco option has been configured.

The summary of the changes are:

  • Add Jacoco’s maven plugin to the project’s pom.xml file.

  • Add coveralls' maven plugin to the project’s pom.xml file.

  • Add TravisCi’s configuration to .travis.yml:

install:
  - mvn test-compile -DskipTests=true -Dmaven.javadoc.skip=true -B -V
script:
  - mvn test jacoco:report
after_success:
  - mvn coveralls:report

Coverage revision

If everything is OK, Coveralls reports should be updated on every PR and merge done on the repo, and be available here.


1. For Gradle projects, see coveralls-gradle-plugin, apart from the project configuration section, the same steps apply.