Skip to content

Commit

Permalink
Merge branch 'fix-coveralls-for-multimodule-project'
Browse files Browse the repository at this point in the history
* fix-coveralls-for-multimodule-project:
  fix coveralls plugin to work with multi-module project
  • Loading branch information
aaschmid committed Jul 10, 2018
2 parents 4f5d722 + f9ec357 commit 243ce7f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jdk:

after_success:
- cd ${TRAVIS_BUILD_DIR}
- ./gradlew jacocoTestReport coveralls
- ./gradlew jacocoRootReport coveralls
35 changes: 34 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ buildscript {
}

plugins {
id 'com.github.kt3k.coveralls' version '2.3.1'
id 'de.aaschmid.cpd' version '1.1'

id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.6.3'
}

ext {
Expand Down Expand Up @@ -317,6 +319,37 @@ cpdCheck {
source = subprojects*.sourceSets*.main*.java*.srcDirs + subprojects*.sourceSets*.test*.java*.srcDirs // only check java source code
}

// -- coveralls gradle plugin multi-module project workaround ---------------------------------------------------------
def publishedProjects = subprojects.findAll()

task jacocoMerge(type: JacocoMerge) {
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
publishedProjects.each { subproject ->
executionData subproject.tasks.withType(Test)
}
}

task jacocoRootReport(type: JacocoReport) {
description = 'Generates an aggregate report from all subprojects'
dependsOn publishedProjects.test, jacocoMerge

additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(publishedProjects.sourceSets.main.output)
executionData jacocoMerge.destinationFile

reports {
xml.enabled = true // required by coveralls
}
}

coveralls {
sourceDirs = publishedProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}

// -- build and publish artifacts -------------------------------------------------------------------------------------
if (!hasProperty('sonatypeUsername')) {
ext.sonatypeUsername = ''
Expand Down

0 comments on commit 243ce7f

Please sign in to comment.