Skip to content

Commit 39935d8

Browse files
authored
Merge pull request #380 from marklogic/feature/sonar-config
Hopefully fixing sonarqube code coverage
2 parents 98fdb30 + 49ce6e5 commit 39935d8

File tree

8 files changed

+26
-27
lines changed

8 files changed

+26
-27
lines changed

Jenkinsfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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.
53
def runtests(String javaVersion){
64
sh label:'test', script: '''#!/bin/bash
75
export JAVA_HOME=$'''+javaVersion+'''
@@ -13,7 +11,7 @@ def runtests(String javaVersion){
1311
./gradlew -i mlDeploy
1412
echo "Loading data a second time to try to avoid Optic bug with duplicate rows being returned."
1513
./gradlew -i mlLoadData
16-
./gradlew testCodeCoverageReport || true
14+
./gradlew clean testCodeCoverageReport || true
1715
'''
1816
junit '**/build/**/*.xml'
1917
}

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ sonar {
77
properties {
88
property "sonar.projectKey", "marklogic-spark"
99
property "sonar.host.url", "http://localhost:9000"
10-
property "sonar.coverage.jacoco.xmlReportPaths", "marklogic-spark-connector/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
10+
property "sonar.coverage.jacoco.xmlReportPaths", "code-coverage-report/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
1111
}
1212
}
1313

1414
subprojects {
1515
apply plugin: "java-library"
1616
apply plugin: "jacoco"
17-
apply plugin: "org.sonarqube"
1817

1918
group = "com.marklogic"
2019
version "2.5-SNAPSHOT"
@@ -39,7 +38,7 @@ subprojects {
3938
force "org.slf4j:slf4j-api:2.0.13"
4039
}
4140
}
42-
41+
4342
test {
4443
useJUnitPlatform()
4544
finalizedBy jacocoTestReport

code-coverage-report/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// See https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_code_coverage_standalone.html
2+
// for more information on how this file was created.
3+
4+
plugins {
5+
id 'jacoco-report-aggregation'
6+
}
7+
8+
dependencies {
9+
jacocoAggregation project(':marklogic-langchain4j')
10+
jacocoAggregation project(':marklogic-spark-api')
11+
jacocoAggregation project(':marklogic-spark-langchain4j')
12+
jacocoAggregation project(':marklogic-spark-connector')
13+
}
14+
15+
reporting {
16+
reports {
17+
testCodeCoverageReport(JacocoCoverageReport) {
18+
testType = TestSuiteType.UNIT_TEST
19+
}
20+
}
21+
}

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The connector has the following system requirements:
1616
[a Spark distribution](https://spark.apache.org/downloads.html), you must select a distribution that uses Scala 2.12 and not Scala 2.13.
1717
* For writing data, MarkLogic 9.0-9 or higher.
1818
* For reading data, MarkLogic 10.0-9 or higher.
19+
* If using Java to run Spark, Java 11 or higher is required.
1920

2021
In addition, if your MarkLogic cluster has multiple hosts in it, it is highly recommended to put a load balancer in front
2122
of your cluster and have the MarkLogic Spark connector connect through the load balancer.

marklogic-langchain4j/build.gradle

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
//configurations.all {
2-
// // Ensures that slf4j-api 1.x does not appear on the Flux classpath in particular, which can lead to this
3-
// // issue - https://www.slf4j.org/codes.html#StaticLoggerBinder .
4-
// resolutionStrategy {
5-
// force "org.slf4j:slf4j-api:2.0.13"
6-
// }
7-
//}
8-
91
dependencies {
102
compileOnly "com.fasterxml.jackson.core:jackson-databind:2.17.2"
113
api "com.marklogic:marklogic-client-api:7.0.0"

marklogic-spark-connector/build.gradle

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

137
configurations {
@@ -23,11 +17,6 @@ configurations {
2317
}
2418

2519
dependencies {
26-
// Adding these forces code coverage data to be calculated for these subprojects.
27-
jacocoAggregation project(':marklogic-langchain4j')
28-
jacocoAggregation project(':marklogic-spark-api')
29-
jacocoAggregation project(':marklogic-spark-langchain4j')
30-
3120
// This is compileOnly as any environment this is used in will provide the Spark dependencies itself.
3221
compileOnly('org.apache.spark:spark-sql_2.12:' + sparkVersion) {
3322
// Excluded from our ETL tool for size reasons, so excluded here as well to ensure we don't need it.

marklogic-spark-connector/src/test/java/com/marklogic/spark/writer/splitter/SplitXmlDocumentTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.apache.spark.sql.Dataset;
1616
import org.apache.spark.sql.Row;
1717
import org.apache.spark.sql.SaveMode;
18-
import org.jdom2.Namespace;
1918
import org.junit.jupiter.api.Test;
2019

2120
import static org.junit.jupiter.api.Assertions.*;

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include "marklogic-langchain4j", "marklogic-spark-api", "marklogic-spark-langchain4j", "marklogic-spark-connector", "test-app"
1+
include "marklogic-langchain4j", "marklogic-spark-api", "marklogic-spark-langchain4j", "marklogic-spark-connector", "test-app", "code-coverage-report"

0 commit comments

Comments
 (0)