Skip to content

Commit f9a9321

Browse files
authored
Merge pull request #305 from marklogic/feature/fix-sonar
Updated Sonar to latest version
2 parents 9efe84e + 6ffa94d commit f9a9321

File tree

6 files changed

+24
-50
lines changed

6 files changed

+24
-50
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
This guide covers how to develop and test this project. It assumes that you have cloned this repository to your local
22
workstation.
33

4-
You must use Java 11 or higher for developing, testing, and building this project.
4+
You must use Java 11 or higher for developing, testing, and building this project. If you wish to use Sonar as
5+
described below, you must use Java 17 or higher.
56

67
# Setup
78

@@ -44,8 +45,8 @@ To run the tests against the test application, run the following Gradle task:
4445

4546
## Generating code quality reports with SonarQube
4647

47-
In order to use SonarQube, you must have used Docker to run this project's `docker-compose.yml` file and you must
48-
have the services in that file running.
48+
In order to use SonarQube, you must have used Docker to run this project's `docker-compose.yml` file, and you must
49+
have the services in that file running and you must use Java 17 to run the Gradle `sonar` task.
4950

5051
To configure the SonarQube service, perform the following steps:
5152

@@ -61,8 +62,8 @@ To configure the SonarQube service, perform the following steps:
6162
10. Add `systemProp.sonar.token=your token pasted here` to `gradle-local.properties` in the root of your project, creating
6263
that file if it does not exist yet.
6364

64-
To run SonarQube, run the following Gradle tasks, which will run all the tests with code coverage and then generate
65-
a quality report with SonarQube:
65+
To run SonarQube, run the following Gradle tasks using Java 17, which will run all the tests with code coverage and
66+
then generate a quality report with SonarQube:
6667

6768
./gradlew test sonar
6869

@@ -82,13 +83,6 @@ you've introduced on the feature branch you're working on. You can then click on
8283
Note that if you only need results on code smells and vulnerabilities, you can repeatedly run `./gradlew sonar`
8384
without having to re-run the tests.
8485

85-
Our Sonar instance is also configured to scan for dependency vulnerabilities
86-
[via the dependency-check plugin](https://github.com/dependency-check/dependency-check-sonar-plugin). For more
87-
information, see the `dependencyCheck` block in this project's `build.gradle` file. To include dependency check results,
88-
just run the following (it's not included by default when running the `sonar` task):
89-
90-
./gradlew dependencyCheckAnalyze sonar
91-
9286
## Accessing MarkLogic logs in Grafana
9387

9488
This project's `docker-compose-3nodes.yaml` file includes

Jenkinsfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pipeline{
4040
buildDiscarder logRotator(artifactDaysToKeepStr: '7', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '')
4141
}
4242
environment{
43-
JAVA11_HOME_DIR="/home/builder/java/jdk-11.0.2"
43+
JAVA17_HOME_DIR="/home/builder/java/jdk-17.0.2"
4444
GRADLE_DIR =".gradle"
4545
DMC_USER = credentials('MLBUILD_USER')
4646
DMC_PASSWORD = credentials('MLBUILD_PASSWORD')
@@ -61,9 +61,9 @@ pipeline{
6161
docker-compose down -v || true
6262
docker-compose up -d --build
6363
'''
64-
runtests('JAVA11_HOME_DIR')
64+
runtests('JAVA17_HOME_DIR')
6565
withSonarQubeEnv('SONAR_Progress') {
66-
runSonarScan('JAVA11_HOME_DIR')
66+
runSonarScan('JAVA17_HOME_DIR')
6767
}
6868
}
6969
post{
@@ -83,7 +83,7 @@ pipeline{
8383
}
8484
steps{
8585
sh label:'publish', script: '''#!/bin/bash
86-
export JAVA_HOME=$JAVA11_HOME_DIR
86+
export JAVA_HOME=$JAVA17_HOME_DIR
8787
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
8888
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
8989
cp ~/.gradle/gradle.properties $GRADLE_USER_HOME;
@@ -110,7 +110,7 @@ pipeline{
110110
docker-compose down -v || true
111111
MARKLOGIC_TAG=latest-10.0 docker-compose up -d --build
112112
'''
113-
runtests('JAVA11_HOME_DIR')
113+
runtests('JAVA17_HOME_DIR')
114114
}
115115
post{
116116
always{

build.gradle

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@ plugins {
22
id 'java-library'
33
id 'net.saliman.properties' version '1.5.2'
44
id 'com.github.johnrengelman.shadow' version '8.1.1'
5-
id "com.marklogic.ml-gradle" version "4.7.0"
5+
id "com.marklogic.ml-gradle" version "5.0.0"
66
id 'maven-publish'
7-
id 'signing'
87
id "jacoco"
9-
id "org.sonarqube" version "4.4.1.3373"
10-
id "org.owasp.dependencycheck" version "10.0.3"
8+
id "org.sonarqube" version "5.1.0.4882"
119
}
1210

1311
group 'com.marklogic'
1412
version '2.4-SNAPSHOT'
1513

1614
java {
17-
// To support reading RDF files, Apache Jena is used - but that requires Java 11. If we want to do a 2.2.0 release
18-
// without requiring Java 11, we'll remove the support for reading RDF files along with the Jena dependency.
15+
// To support reading RDF files, Apache Jena is used - but that requires Java 11.
1916
sourceCompatibility = 11
2017
targetCompatibility = 11
2118
}
@@ -55,7 +52,7 @@ dependencies {
5552
exclude group: "com.fasterxml.jackson.dataformat"
5653
}
5754

58-
// Required for converting JSON to XML. Using 2.14.2 to align with Spark 3.4.1.
55+
// Required for converting JSON to XML. Using 2.14.2 to align with Spark 3.4.3.
5956
shadowDependencies "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.14.2"
6057

6158
// Need this so that an OkHttpClientConfigurator can be created.
@@ -68,7 +65,7 @@ dependencies {
6865

6966
shadowDependencies "org.jdom:jdom2:2.0.6.1"
7067

71-
testImplementation ('com.marklogic:ml-app-deployer:4.8.0') {
68+
testImplementation ('com.marklogic:ml-app-deployer:5.0.0') {
7269
exclude group: "com.fasterxml.jackson.core"
7370
exclude group: "com.fasterxml.jackson.dataformat"
7471

@@ -85,20 +82,10 @@ dependencies {
8582
}
8683

8784
testImplementation "ch.qos.logback:logback-classic:1.3.14"
88-
testImplementation "org.slf4j:jcl-over-slf4j:1.7.36"
85+
testImplementation "org.slf4j:jcl-over-slf4j:2.0.13"
8986
testImplementation "org.skyscreamer:jsonassert:1.5.1"
9087
}
9188

92-
// See https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html for more information.
93-
dependencyCheck {
94-
// Need a JSON report to integrate with Sonar. And HTML is easier for humans to read.
95-
formats = ["HTML", "JSON"]
96-
// We don't include compileOnly since that includes Spark, and Spark and its dependencies are not actual dependencies
97-
// of our connector.
98-
scanConfigurations = ["shadowDependencies"]
99-
suppressionFile = "config/dependency-check-suppressions.xml"
100-
}
101-
10289
test {
10390
useJUnitPlatform()
10491
finalizedBy jacocoTestReport
@@ -136,7 +123,8 @@ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
136123
// for an explanation of why these are needed when running the tests on Java 17.
137124
jvmArgs = [
138125
'--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
139-
'--add-opens=java.base/sun.util.calendar=ALL-UNNAMED'
126+
'--add-opens=java.base/sun.util.calendar=ALL-UNNAMED',
127+
'--add-opens=java.base/sun.security.action=ALL-UNNAMED'
140128
]
141129
}
142130
}
@@ -178,9 +166,6 @@ javadoc.options.addStringOption('Xdoclint:none', '-quiet')
178166
artifacts {
179167
archives javadocJar, sourcesJar
180168
}
181-
signing {
182-
sign configurations.archives
183-
}
184169

185170
publishing {
186171
publications {

docker-compose.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,20 @@ services:
1919

2020
# Copied from https://docs.sonarsource.com/sonarqube/latest/setup-and-upgrade/install-the-server/#example-docker-compose-configuration .
2121
sonarqube:
22-
# Using 10.2 to avoid requiring Java 17 for now.
23-
image: sonarqube:10.2.1-community
22+
image: sonarqube:10.6.0-community
2423
depends_on:
2524
- postgres
2625
environment:
2726
SONAR_JDBC_URL: jdbc:postgresql://postgres:5432/sonar
2827
SONAR_JDBC_USERNAME: sonar
2928
SONAR_JDBC_PASSWORD: sonar
3029
volumes:
31-
- ./docker/sonarqube/data:/opt/sonarqube/data
32-
- ./docker/sonarqube/logs:/opt/sonarqube/logs
33-
# Allows for Sonar plugins to be installed by including plugin jar files in this directory.
34-
- ./docker/sonarqube/extensions:/opt/sonarqube/extensions
30+
- sonarqube_data:/opt/sonarqube/data
3531
ports:
3632
- "9000:9000"
3733

3834
postgres:
39-
image: postgres:12
35+
image: postgres:15
4036
environment:
4137
POSTGRES_USER: sonar
4238
POSTGRES_PASSWORD: sonar
@@ -46,7 +42,5 @@ services:
4642

4743
volumes:
4844
sonarqube_data:
49-
sonarqube_extensions:
50-
sonarqube_logs:
5145
postgresql:
5246
postgresql_data:
Binary file not shown.

src/main/java/com/marklogic/spark/reader/file/ZipFileReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public boolean next() {
5555
currentZipEntry = FileUtil.findNextFileEntry(currentZipInputStream);
5656
} catch (IOException e) {
5757
throw new ConnectorException(String.format(
58-
"Unable to read from zip file %s; cause: %s", currentFilePath, e.getMessage(), e));
58+
"Unable to read from zip file %s; cause: %s", currentFilePath, e.getMessage()), e);
5959
}
60+
6061
if (currentZipEntry != null) {
6162
return true;
6263
}

0 commit comments

Comments
 (0)