Skip to content

Commit 687c009

Browse files
authored
Merge pull request #363 from marklogic/feature/code-coverage
Giving up on multi-project Sonar code coverage for now
2 parents 1a53723 + 023be76 commit 687c009

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

Jenkinsfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@Library('shared-libraries') _
22

3+
// Using testCodeCoverageReport from the jacoco-report-aggregation plugin to produce an aggregated code coverage
4+
// report, even though Sonar doesn't seem to be able to make sense of it yet.
35
def runtests(String javaVersion){
46
sh label:'test', script: '''#!/bin/bash
57
export JAVA_HOME=$'''+javaVersion+'''
@@ -12,7 +14,7 @@ def runtests(String javaVersion){
1214
./gradlew -i mlDeploy
1315
echo "Loading data a second time to try to avoid Optic bug with duplicate rows being returned."
1416
./gradlew -i mlLoadData
15-
./gradlew test || true
17+
./gradlew testCodeCoverageReport || true
1618
'''
1719
junit '**/build/**/*.xml'
1820
}

build.gradle

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
plugins {
22
id "java-library"
3-
id "jacoco-report-aggregation"
43
id "org.sonarqube" version "5.1.0.4882"
54
}
65

7-
// See https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_code_coverage_standalone.html .
8-
// This isn't picking up jacoco coverage of all the subprojects. Will figure that out soon.
9-
dependencies {
10-
jacocoAggregation project(':marklogic-langchain4j')
11-
jacocoAggregation project(':marklogic-spark-api')
12-
jacocoAggregation project(':marklogic-spark-langchain4j')
13-
jacocoAggregation project(':marklogic-spark-connector')
14-
}
15-
166
sonar {
177
properties {
188
property "sonar.projectKey", "marklogic-spark"
199
property "sonar.host.url", "http://localhost:9000"
10+
property "sonar.coverage.jacoco.xmlReportPaths", "marklogic-spark-connector/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
2011
}
2112
}
2213

marklogic-spark-connector/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ plugins {
33
id 'com.gradleup.shadow' version '8.3.3'
44
id "com.marklogic.ml-gradle" version "5.0.0"
55
id 'maven-publish'
6+
7+
// This is working in terms of nicely aggregating jacoco code coverage data from each subproject. It produces a very
8+
// nice HTML report under build/reports/jacoco/testCodeCoverageReport. Unfortunately, Sonar doesn't seem able to get
9+
// all the coverage data from this directory; it only reports coverage from this project. Something to be figured out
10+
// later.
11+
id "jacoco-report-aggregation"
612
}
713

814
configurations {
@@ -26,6 +32,11 @@ configurations.all {
2632
}
2733

2834
dependencies {
35+
// Adding these forces code coverage data to be calculated for these subprojects.
36+
jacocoAggregation project(':marklogic-langchain4j')
37+
jacocoAggregation project(':marklogic-spark-api')
38+
jacocoAggregation project(':marklogic-spark-langchain4j')
39+
2940
// This is compileOnly as any environment this is used in will provide the Spark dependencies itself.
3041
compileOnly('org.apache.spark:spark-sql_2.12:' + sparkVersion) {
3142
// Excluded from our ETL tool for size reasons, so excluded here as well to ensure we don't need it.

0 commit comments

Comments
 (0)