Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ Gradle:
$ gradle jar # build jar file (build/libs/watson-developer-cloud-3.5.3.jar)
$ gradle test # run tests
$ gradle check # performs quality checks on source files and generates reports
$ gradle testReport # run tests and generate the aggregated test report (build/reports/allTests)
$ gradle codeCoverageReport # run tests and generate the code coverage report (build/reports/jacoco)
```


Expand Down
38 changes: 38 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ task docs(type: Javadoc) {

allprojects {
apply plugin: 'java' // *Compatibility has no effect before the 'java' plug-in is applied
apply plugin: 'jacoco'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

repositories {
mavenCentral()
}
}

subprojects {
Expand All @@ -35,3 +41,35 @@ subprojects {
}
}
}

task codeCoverageReport(type: JacocoReport) {
// Gather execution data from all sub projects
// (change this if you e.g. want to calculate unit test/integration test coverage separately)
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

// Add all relevant source sets from the sub projects
subprojects.each {
sourceSets it.sourceSets.main
}

reports {
xml.enabled true
xml.destination "${buildDir}/reports/jacoco/report.xml"
html.enabled true
html.destination "${buildDir}/reports/jacoco"
csv.enabled false
}
}

// always run the tests before generating the report
codeCoverageReport.dependsOn {
subprojects*.test
testReport
}

task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")

// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}