|
1 |
| -plugins { |
2 |
| - id 'java-library' |
3 |
| - id 'net.saliman.properties' version '1.5.2' |
4 |
| - id 'com.github.johnrengelman.shadow' version '8.1.1' |
5 |
| - id "com.marklogic.ml-gradle" version "5.0.0" |
6 |
| - id 'maven-publish' |
7 |
| - id "jacoco" |
8 |
| - id "org.sonarqube" version "5.1.0.4882" |
9 |
| -} |
10 |
| - |
11 |
| -group 'com.marklogic' |
12 |
| -version '2.5-SNAPSHOT' |
13 |
| - |
14 |
| -java { |
15 |
| - // To support reading RDF files, Apache Jena is used - but that requires Java 11. |
16 |
| - sourceCompatibility = 11 |
17 |
| - targetCompatibility = 11 |
18 |
| -} |
19 |
| - |
20 |
| -repositories { |
21 |
| - mavenCentral() |
22 |
| - mavenLocal() |
23 |
| - maven { |
24 |
| - url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/" |
25 |
| - } |
26 |
| -} |
27 |
| - |
28 |
| -configurations { |
29 |
| - // Defines all the implementation dependencies, but in such a way that they are not included as dependencies in the |
30 |
| - // library's pom.xml file. This is due to the shadow jar being published instead of a jar only containing this |
31 |
| - // project's classes. The shadow jar is published due to the need to relocate several packages to avoid conflicts |
32 |
| - // with Spark. |
33 |
| - shadowDependencies |
34 |
| - |
35 |
| - // This approach allows for all of the dependencies to be available for compilation and for running tests. |
36 |
| - compileOnly.extendsFrom(shadowDependencies) |
37 |
| - testImplementation.extendsFrom(compileOnly) |
38 |
| -} |
39 |
| - |
40 |
| -configurations.all { |
41 |
| - // Ensures that slf4j-api 1.x does not appear on the Flux classpath in particular, which can lead to this |
42 |
| - // issue - https://www.slf4j.org/codes.html#StaticLoggerBinder . |
43 |
| - resolutionStrategy { |
44 |
| - force "org.slf4j:slf4j-api:2.0.13" |
45 |
| - } |
46 |
| -} |
47 |
| - |
48 |
| -dependencies { |
49 |
| - // This is compileOnly as any environment this is used in will provide the Spark dependencies itself. |
50 |
| - compileOnly ('org.apache.spark:spark-sql_2.12:' + sparkVersion) { |
51 |
| - // Excluded from our ETL tool for size reasons, so excluded here as well to ensure we don't need it. |
52 |
| - exclude module: "rocksdbjni" |
53 |
| - } |
| 1 | +subprojects { |
| 2 | + apply plugin: "java-library" |
54 | 3 |
|
55 |
| - shadowDependencies ("com.marklogic:marklogic-client-api:7.0.0") { |
56 |
| - // The Java Client uses Jackson 2.15.2; Scala 3.4.x does not yet support that and will throw the following error: |
57 |
| - // Scala module 2.14.2 requires Jackson Databind version >= 2.14.0 and < 2.15.0 - Found jackson-databind version 2.15.2 |
58 |
| - // So the 4 Jackson modules are excluded to allow for Spark's to be used. |
59 |
| - exclude group: "com.fasterxml.jackson.core" |
60 |
| - exclude group: "com.fasterxml.jackson.dataformat" |
61 |
| - } |
62 |
| - |
63 |
| - // Required for converting JSON to XML. Using 2.15.2 to align with Spark 3.5.3. |
64 |
| - shadowDependencies ("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.2") { |
65 |
| - // Not needed, as the modules in this group that this dependency depends on are all provided by Spark. |
66 |
| - exclude group: "com.fasterxml.jackson.core" |
67 |
| - } |
68 |
| - |
69 |
| - // Need this so that an OkHttpClientConfigurator can be created. |
70 |
| - shadowDependencies 'com.squareup.okhttp3:okhttp:4.12.0' |
| 4 | + group = "com.marklogic" |
| 5 | + version '2.5-SNAPSHOT' |
71 | 6 |
|
72 |
| - // Supports reading and writing RDF data. |
73 |
| - shadowDependencies ("org.apache.jena:jena-arq:4.10.0") { |
74 |
| - exclude group: "com.fasterxml.jackson.core" |
75 |
| - exclude group: "com.fasterxml.jackson.dataformat" |
| 7 | + java { |
| 8 | + sourceCompatibility = 11 |
| 9 | + targetCompatibility = 11 |
76 | 10 | }
|
77 | 11 |
|
78 |
| - // Supports splitting documents. |
79 |
| - shadowDependencies "dev.langchain4j:langchain4j:0.35.0" |
80 |
| - |
81 |
| - // Supports testing the embedder feature. |
82 |
| - testImplementation "dev.langchain4j:langchain4j-embeddings-all-minilm-l6-v2:0.35.0" |
83 |
| - |
84 |
| - // Needed for some XML operations that are far easier with JDOM2 than with DOM. |
85 |
| - shadowDependencies "org.jdom:jdom2:2.0.6.1" |
86 |
| - |
87 |
| - // Needed for splitting XML documents via XPath. |
88 |
| - shadowDependencies "jaxen:jaxen:2.0.0" |
89 |
| - |
90 |
| - testImplementation ('com.marklogic:ml-app-deployer:5.0.0') { |
91 |
| - exclude group: "com.fasterxml.jackson.core" |
92 |
| - exclude group: "com.fasterxml.jackson.dataformat" |
93 |
| - |
94 |
| - // Use the Java Client declared above. |
95 |
| - exclude module: "marklogic-client-api" |
96 |
| - } |
97 |
| - |
98 |
| - testImplementation ('com.marklogic:marklogic-junit5:1.5.0') { |
99 |
| - exclude group: "com.fasterxml.jackson.core" |
100 |
| - exclude group: "com.fasterxml.jackson.dataformat" |
101 |
| - |
102 |
| - // Use the Java Client declared above. |
103 |
| - exclude module: "marklogic-client-api" |
104 |
| - } |
105 |
| - |
106 |
| - testImplementation "ch.qos.logback:logback-classic:1.3.14" |
107 |
| - testImplementation "org.slf4j:jcl-over-slf4j:2.0.13" |
108 |
| - testImplementation "org.skyscreamer:jsonassert:1.5.1" |
109 |
| -} |
110 |
| - |
111 |
| -test { |
112 |
| - useJUnitPlatform() |
113 |
| - finalizedBy jacocoTestReport |
114 |
| - // Allows mlHost to override the value in gradle.properties, which the test plumbing will default to. |
115 |
| - environment "mlHost", mlHost |
116 |
| -} |
117 |
| - |
118 |
| -// See https://docs.gradle.org/current/userguide/jacoco_plugin.html . |
119 |
| -jacocoTestReport { |
120 |
| - dependsOn test |
121 |
| - reports { |
122 |
| - xml.required = true |
123 |
| - } |
124 |
| -} |
125 |
| - |
126 |
| -sonar { |
127 |
| - properties { |
128 |
| - property "sonar.projectKey", "marklogic-spark" |
129 |
| - property "sonar.host.url", "http://localhost:9000" |
130 |
| - } |
131 |
| -} |
132 |
| - |
133 |
| -task reloadTestData(type: com.marklogic.gradle.task.MarkLogicTask) { |
134 |
| - description = "Convenience task for clearing the test database and reloading the test data; only intended for a connector developer to use." |
135 |
| - doLast { |
136 |
| - new com.marklogic.mgmt.resource.databases.DatabaseManager(getManageClient()).clearDatabase("spark-test-test-content") |
137 |
| - } |
138 |
| -} |
139 |
| -reloadTestData.finalizedBy mlLoadData |
140 |
| - |
141 |
| -if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) { |
142 |
| - test { |
143 |
| - // See https://stackoverflow.com/questions/72724816/running-unit-tests-with-spark-3-3-0-on-java-17-fails-with-illegalaccesserror-cl |
144 |
| - // for an explanation of why these are needed when running the tests on Java 17. |
145 |
| - jvmArgs = [ |
146 |
| - '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED', |
147 |
| - '--add-opens=java.base/sun.util.calendar=ALL-UNNAMED', |
148 |
| - '--add-opens=java.base/sun.security.action=ALL-UNNAMED' |
149 |
| - ] |
150 |
| - } |
151 |
| -} |
152 |
| - |
153 |
| -shadowJar { |
154 |
| - configurations = [project.configurations.shadowDependencies] |
155 |
| - |
156 |
| - // "all" is the default; no need for that in the connector filename. This also results in this becoming the library |
157 |
| - // artifact that is published as a dependency. That is desirable as it includes the relocated packages listed below, |
158 |
| - // which a dependent would otherwise have to manage themselves. |
159 |
| - archiveClassifier.set("") |
160 |
| - |
161 |
| - // Spark uses an older version of OkHttp; see |
162 |
| - // https://stackoverflow.com/questions/61147800/how-to-override-spark-jars-while-running-spark-submit-command-in-cluster-mode |
163 |
| - // for more information on why these are relocated. |
164 |
| - relocate "okhttp3", "com.marklogic.okhttp3" |
165 |
| - relocate "okio", "com.marklogic.okio" |
166 |
| -} |
167 |
| - |
168 |
| -// Publishing setup - see https://docs.gradle.org/current/userguide/publishing_setup.html . |
169 |
| -java { |
170 |
| - withJavadocJar() |
171 |
| - withSourcesJar() |
172 |
| -} |
173 |
| - |
174 |
| -javadoc.failOnError = false |
175 |
| -// Ignores warnings on params that don't have descriptions, which is a little too noisy |
176 |
| -javadoc.options.addStringOption('Xdoclint:none', '-quiet') |
177 |
| - |
178 |
| -publishing { |
179 |
| - publications { |
180 |
| - mainJava(MavenPublication) { |
181 |
| - pom { |
182 |
| - name = "${group}:${project.name}" |
183 |
| - description = "Spark 3 connector for MarkLogic" |
184 |
| - packaging = "jar" |
185 |
| - from components.java |
186 |
| - url = "https://github.com/marklogic/${project.name}" |
187 |
| - licenses { |
188 |
| - license { |
189 |
| - name = "The Apache License, Version 2.0" |
190 |
| - url = "http://www.apache.org/licenses/LICENSE-2.0.txt" |
191 |
| - } |
192 |
| - } |
193 |
| - developers { |
194 |
| - developer { |
195 |
| - id = "marklogic" |
196 |
| - name = "MarkLogic Github Contributors" |
197 |
| - email = "general@developer.marklogic.com" |
198 |
| - organization = "MarkLogic" |
199 |
| - organizationUrl = "https://www.marklogic.com" |
200 |
| - } |
201 |
| - } |
202 |
| - scm { |
203 |
| - url = "git@github.com:marklogic/${project.name}.git" |
204 |
| - connection = "scm:git@github.com:marklogic/${project.name}.git" |
205 |
| - developerConnection = "scm:git@github.com:marklogic/${project.name}.git" |
206 |
| - } |
207 |
| - } |
208 |
| - } |
209 |
| - } |
210 | 12 | repositories {
|
| 13 | + mavenCentral() |
| 14 | + mavenLocal() |
211 | 15 | maven {
|
212 |
| - if (project.hasProperty("mavenUser")) { |
213 |
| - credentials { |
214 |
| - username mavenUser |
215 |
| - password mavenPassword |
216 |
| - } |
217 |
| - url publishUrl |
218 |
| - allowInsecureProtocol = true |
219 |
| - } else { |
220 |
| - name = "central" |
221 |
| - url = mavenCentralUrl |
222 |
| - credentials { |
223 |
| - username mavenCentralUsername |
224 |
| - password mavenCentralPassword |
225 |
| - } |
226 |
| - } |
| 16 | + url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/" |
227 | 17 | }
|
228 | 18 | }
|
229 |
| -} |
230 | 19 |
|
231 |
| -task gettingStartedZip(type: Zip) { |
232 |
| - description = "Creates a zip of the getting-started project that is intended to be included as a downloadable file " + |
233 |
| - "on the GitHub release page." |
234 |
| - from "examples/getting-started" |
235 |
| - exclude "build", ".gradle", "gradle-*.properties", ".venv", "venv", "docker" |
236 |
| - into "marklogic-spark-getting-started-${version}" |
237 |
| - archiveFileName = "marklogic-spark-getting-started-${version}.zip" |
238 |
| - destinationDirectory = file("build") |
239 |
| -} |
240 |
| - |
241 |
| -tasks.register("addMarkLogic12SchemasIfNecessary", com.marklogic.gradle.task.MarkLogicTask) { |
242 |
| - description = "If testing against MarkLogic 12, include schemas that will not work on MarkLogic 11 or earlier." |
243 |
| - doLast { |
244 |
| - def version = new com.marklogic.mgmt.resource.clusters.ClusterManager(getManageClient()).getVersion() |
245 |
| - if (version.startsWith("12.")) { |
246 |
| - mlAppConfig.getSchemaPaths().add(new File(getProjectDir(), "src/test/ml-schemas-12").getAbsolutePath()) |
| 20 | + test { |
| 21 | + useJUnitPlatform() |
| 22 | + testLogging { |
| 23 | + events 'started', 'passed', 'skipped', 'failed' |
| 24 | + exceptionFormat 'full' |
247 | 25 | }
|
248 | 26 | }
|
249 | 27 | }
|
250 |
| -mlDeploy.dependsOn addMarkLogic12SchemasIfNecessary |
251 |
| -mlLoadSchemas.dependsOn addMarkLogic12SchemasIfNecessary |
0 commit comments