@@ -2,61 +2,74 @@ 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.6 .0"
5+ id " com.marklogic.ml-gradle" version " 4.7 .0"
66 id ' maven-publish'
77 id ' signing'
88 id " jacoco"
99 id " org.sonarqube" version " 4.4.1.3373"
1010}
1111
1212group ' com.marklogic'
13- version ' 2.2.0 '
13+ version ' 2.3.0.rc1 '
1414
1515java {
16- sourceCompatibility = 1.8
17- targetCompatibility = 1.8
16+ // To support reading RDF files, Apache Jena is used - but that requires Java 11. If we want to do a 2.2.0 release
17+ // without requiring Java 11, we'll remove the support for reading RDF files along with the Jena dependency.
18+ sourceCompatibility = 11
19+ targetCompatibility = 11
1820}
1921
2022repositories {
2123 mavenCentral()
2224}
2325
26+ configurations {
27+ // Defines all the implementation dependencies, but in such a way that they are not included as dependencies in the
28+ // library's pom.xml file. This is due to the shadow jar being published instead of a jar only containing this
29+ // project's classes. The shadow jar is published due to the need to relocate several packages to avoid conflicts
30+ // with Spark.
31+ shadowDependencies
32+
33+ // This approach allows for all of the dependencies to be available for compilation and for running tests.
34+ compileOnly. extendsFrom(shadowDependencies)
35+ testImplementation. extendsFrom(compileOnly)
36+ }
37+
2438dependencies {
25- compileOnly ' org.apache.spark:spark-sql_2.12:' + sparkVersion
26- implementation (" com.marklogic:marklogic-client-api:6.5.0" ) {
39+ // This is compileOnly as any environment this is used in will provide the Spark dependencies itself.
40+ compileOnly (' org.apache.spark:spark-sql_2.12:' + sparkVersion) {
41+ // Excluded from our ETL tool for size reasons, so excluded here as well to ensure we don't need it.
42+ exclude module : " rocksdbjni"
43+ }
44+
45+ shadowDependencies (" com.marklogic:marklogic-client-api:6.6.1" ) {
2746 // The Java Client uses Jackson 2.15.2; Scala 3.4.x does not yet support that and will throw the following error:
2847 // Scala module 2.14.2 requires Jackson Databind version >= 2.14.0 and < 2.15.0 - Found jackson-databind version 2.15.2
2948 // So the 4 Jackson modules are excluded to allow for Spark's to be used.
30- exclude module : ' jackson-core'
31- exclude module : ' jackson-databind'
32- exclude module : ' jackson-annotations'
33- exclude module : ' jackson-dataformat-csv'
49+ exclude group : " com.fasterxml.jackson.core"
50+ exclude group : " com.fasterxml.jackson.dataformat"
3451 }
3552
53+ // Required for converting JSON to XML. Using 2.14.2 to align with Spark 3.4.1.
54+ shadowDependencies " com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.14.2"
55+
3656 // Need this so that an OkHttpClientConfigurator can be created.
37- implementation ' com.squareup.okhttp3:okhttp:4.12.0'
57+ shadowDependencies ' com.squareup.okhttp3:okhttp:4.12.0'
3858
39- // Makes it possible to use lambdas in Java 8 to implement Spark's Function1 and Function2 interfaces
40- // See https://github.com/scala/scala-java8-compat for more information
41- implementation(" org.scala-lang.modules:scala-java8-compat_2.12:1.0.2" ) {
42- // Prefer the Scala libraries used within the user's Spark runtime.
43- exclude module : " scala-library"
59+ shadowDependencies (" org.apache.jena:jena-arq:4.10.0" ) {
60+ exclude group : " com.fasterxml.jackson.core"
61+ exclude group : " com.fasterxml.jackson.dataformat"
4462 }
4563
46- testImplementation ' org.apache.spark:spark-sql_2.12: ' + sparkVersion
64+ shadowDependencies " org.jdom:jdom2:2.0.6.1 "
4765
48- // The exclusions in these two modules ensure that we use the Jackson libraries from spark-sql when running the tests.
49- testImplementation (' com.marklogic:ml-app-deployer:4.6.0' ) {
50- exclude module : ' jackson-core'
51- exclude module : ' jackson-databind'
52- exclude module : ' jackson-annotations'
53- exclude module : ' jackson-dataformat-csv'
66+ testImplementation (' com.marklogic:ml-app-deployer:4.7.0' ) {
67+ exclude group : " com.fasterxml.jackson.core"
68+ exclude group : " com.fasterxml.jackson.dataformat"
5469 }
5570 testImplementation (' com.marklogic:marklogic-junit5:1.4.0' ) {
56- exclude module : ' jackson-core'
57- exclude module : ' jackson-databind'
58- exclude module : ' jackson-annotations'
59- exclude module : ' jackson-dataformat-csv'
71+ exclude group : " com.fasterxml.jackson.core"
72+ exclude group : " com.fasterxml.jackson.dataformat"
6073 }
6174
6275 testImplementation " ch.qos.logback:logback-classic:1.3.14"
@@ -105,7 +118,11 @@ if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
105118}
106119
107120shadowJar {
108- // "all" is the default; no need for that in the connector filename.
121+ configurations = [project. configurations. shadowDependencies]
122+
123+ // "all" is the default; no need for that in the connector filename. This also results in this becoming the library
124+ // artifact that is published as a dependency. That is desirable as it includes the relocated packages listed below,
125+ // which a dependent would otherwise have to manage themselves.
109126 archiveClassifier. set(" " )
110127
111128 // Spark uses an older version of OkHttp; see
@@ -121,38 +138,6 @@ task perfTest(type: JavaExec) {
121138 args mlHost
122139}
123140
124- task dockerBuildCache (type : Exec ) {
125- description = " Creates an image named 'marklogic-spark-cache' containing a cache of the Gradle dependencies."
126- commandLine ' docker' , ' build' , ' --no-cache' , ' -t' , ' marklogic-spark-cache' , ' .'
127- }
128-
129- task dockerTest (type : Exec ) {
130- description = " Run all of the tests within a Docker environment."
131- commandLine ' docker' , ' run' ,
132- // Allows for communicating with the MarkLogic cluster that is setup via docker-compose.yaml.
133- ' --network=marklogic_spark_external_net' ,
134- // Map the project directory into the Docker container.
135- ' -v' , getProjectDir(). getAbsolutePath() + ' :/root/project' ,
136- // Working directory for the Gradle tasks below.
137- ' -w' , ' /root/project' ,
138- // Remove the container after it finishes running.
139- ' --rm' ,
140- // Use the output of dockerBuildCache to avoid downloading all the Gradle dependencies.
141- ' marklogic-spark-cache:latest' ,
142- ' gradle' , ' -i' , ' -PmlHost=bootstrap_3n.local' , ' test'
143- }
144-
145- task dockerPerfTest (type : Exec ) {
146- description = " Run PerformanceTester a Docker environment."
147- commandLine ' docker' , ' run' ,
148- ' --network=marklogic_spark_external_net' ,
149- ' -v' , getProjectDir(). getAbsolutePath() + ' :/root/project' ,
150- ' -w' , ' /root/project' ,
151- ' --rm' ,
152- ' marklogic-spark-cache:latest' ,
153- ' gradle' , ' -i' , ' -PmlHost=bootstrap_3n.local' , ' perfTest'
154- }
155-
156141task sourcesJar (type : Jar , dependsOn : classes) {
157142 archiveClassifier = " sources"
158143 from sourceSets. main. allSource
0 commit comments