Skip to content

Commit 0fd8fc7

Browse files
authored
Merge pull request #360 from marklogic/feature/refactor-subproject
Moving all connector code to subprojec
2 parents 75266fe + 1e5357a commit 0fd8fc7

File tree

438 files changed

+377
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

438 files changed

+377
-347
lines changed

build.gradle

Lines changed: 15 additions & 239 deletions
Original file line numberDiff line numberDiff line change
@@ -1,251 +1,27 @@
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"
543

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'
716

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
7610
}
7711

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-
}
21012
repositories {
13+
mavenCentral()
14+
mavenLocal()
21115
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/"
22717
}
22818
}
229-
}
23019

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'
24725
}
24826
}
24927
}
250-
mlDeploy.dependsOn addMarkLogic12SchemasIfNecessary
251-
mlLoadSchemas.dependsOn addMarkLogic12SchemasIfNecessary

gradle/wrapper/gradle-wrapper.jar

-16.8 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +82,12 @@ do
8082
esac
8183
done
8284

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
85+
# This is normally unused
86+
# shellcheck disable=SC2034
8687
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
88+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
9091

9192
# Use the maximum available, or set MAX_FD != -1 to use that value.
9293
MAX_FD=maximum
@@ -133,22 +134,29 @@ location of your Java installation."
133134
fi
134135
else
135136
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
if ! command -v java >/dev/null 2>&1
138+
then
139+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137140
138141
Please set the JAVA_HOME variable in your environment to match the
139142
location of your Java installation."
143+
fi
140144
fi
141145

142146
# Increase the maximum file descriptors if we can.
143147
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144148
case $MAX_FD in #(
145149
max*)
150+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151+
# shellcheck disable=SC2039,SC3045
146152
MAX_FD=$( ulimit -H -n ) ||
147153
warn "Could not query maximum file descriptor limit"
148154
esac
149155
case $MAX_FD in #(
150156
'' | soft) :;; #(
151157
*)
158+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159+
# shellcheck disable=SC2039,SC3045
152160
ulimit -n "$MAX_FD" ||
153161
warn "Could not set maximum file descriptor limit to $MAX_FD"
154162
esac
@@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then
193201
done
194202
fi
195203

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
204+
205+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207+
208+
# Collect all arguments for the java command:
209+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210+
# and any embedded shellness will be escaped.
211+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212+
# treated as '${Hostname}' itself on the command line.
201213

202214
set -- \
203215
"-Dorg.gradle.appname=$APP_BASE_NAME" \

0 commit comments

Comments
 (0)