Skip to content

Commit 57d6f9b

Browse files
committed
Updated README to address how to use Java Client on Java 11 and 17
This addresses a gap in the docs where we've never explained how to include JAXB if a user is using Java 11 or 17 and wishes to use the JAXB support in the Java Client. Can also now build and run all the tests using Java 11 or 17 (we've only used Java 8 before). That simply required the following: - Don't fail the build on javadoc errors; Java 11 is much more particular about these, and we ought to do a cleanup of these errors soon, but we can ignore them for now - Bumped up Gradle wrapper version to the latest 7.x; to build and run on Java 17, need at least Gradle 7.3 - Bumped up Mockito from the very, very old mockito-all dependency (last updated in 2015) to the latest ones; this fixed a simple problem with Mockito that popped up when testing with Java 11 and Java 17 - Added a duplicatesStrategy for ml-development-tools to address an issue where the plugin properties file was getting copied over twice; this occurred as a result of upgrading from Gradle 6 to 7. There is likely a better way to handle this, but this approach (which the error message recommends using) works for now.
1 parent 02c458d commit 57d6f9b

File tree

5 files changed

+68
-8
lines changed

5 files changed

+68
-8
lines changed

README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,59 @@ implemented by an endpoint on the server.
3232

3333
## QuickStart
3434

35-
To use the API in your maven project, include the following in your pom.xml:
35+
To use the API in your [Maven](https://maven.apache.org/) project, include the following in your pom.xml file:
3636

3737
<dependency>
3838
<groupId>com.marklogic</groupId>
3939
<artifactId>marklogic-client-api</artifactId>
4040
<version>6.0.0</version>
4141
</dependency>
4242

43-
For gradle projects, use gradle 4.x+ and include the following:
43+
To use the API in your [Gradle](https://gradle.org/) project, include the following in your build.gradle file:
4444

4545
dependencies {
46-
compile "com.marklogic:marklogic-client-api:6.0.0"
46+
implementation "com.marklogic:marklogic-client-api:6.0.0"
4747
}
4848

49-
Read [The Java API in Five Minutes](http://developer.marklogic.com/try/java/index)
49+
Next, read [The Java API in Five Minutes](http://developer.marklogic.com/try/java/index) to get started.
50+
51+
### Including JAXB support
52+
53+
If you are using Java 11 or higher (including Java 17) and you wish to use [JAXB](https://docs.oracle.com/javase/tutorial/jaxb/intro/)
54+
with the Java Client, you'll need to include JAXB API and implementation dependencies as those are no
55+
longer included in Java 11 and higher.
56+
57+
For Maven, include the following in your pom.xml file:
58+
59+
<dependency>
60+
<groupId>javax.xml.bind</groupId>
61+
<artifactId>jaxb-api</artifactId>
62+
<version>2.3.1</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.glassfish.jaxb</groupId>
66+
<artifactId>jaxb-runtime</artifactId>
67+
<version>2.3.2</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.glassfish.jaxb</groupId>
71+
<artifactId>jaxb-core</artifactId>
72+
<version>2.3.0.1</version>
73+
</dependency>
74+
75+
For Gradle, include the following in your build.gradle file (this can be included in the same `dependencies` block
76+
as the one that includes the marklogic-client-api dependency):
77+
78+
dependencies {
79+
implementation "javax.xml.bind:jaxb-api:2.3.1"
80+
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
81+
implementation "org.glassfish.jaxb:jaxb-core:2.3.0.1"
82+
}
83+
84+
You are free to use any implementation of JAXB that you wish, but you need to ensure that you're using a JAXB
85+
implementation that corresponds to the `javax.xml.bind` interfaces. JAXB 3.0 and 4.0 interfaces are packaged under
86+
`jakarta.xml.bind`, and the Java API does not yet depend on those interfaces. You are thus free to include an
87+
implementation of JAXB 3.0 or 4.0 in your project for your own use; it will not affect the Java API.
5088

5189
### Learning More
5290

build.gradle

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ subprojects {
2121
tasks.withType(JavaCompile) {
2222
options.encoding = 'UTF-8'
2323
}
24-
sourceCompatibility = "1.8"
25-
targetCompatibility = "1.8"
24+
25+
// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.
26+
// May adjust this for src/test/java so that tests can take advantage of more expressive functions in Java 9+, such
27+
// as Map.of().
28+
java {
29+
sourceCompatibility = 1.8
30+
targetCompatibility = 1.8
31+
}
2632

2733
configurations {
2834
testImplementation.extendsFrom compileOnly
@@ -45,4 +51,11 @@ subprojects {
4551
systemProperty "javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl"
4652
}
4753

54+
// Until we do a cleanup of javadoc errors, the build (and specifically the javadoc task) fails on Java 11
55+
// and higher. Preventing that until the cleanup can occur.
56+
javadoc.failOnError = false
57+
58+
// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
59+
// Until then, it's just a lot of noise.
60+
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
4861
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

marklogic-client-api/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ dependencies {
2525
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.4'
2626
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4.2'
2727
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.13.4'
28+
2829
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.4'
29-
testImplementation group: 'org.mockito', name: 'mockito-all', version:'1.10.19'
30+
testImplementation "org.mockito:mockito-core:4.9.0"
31+
testImplementation "org.mockito:mockito-inline:4.9.0"
3032
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version:'1.2.11'
3133
testImplementation group: 'org.hsqldb', name: 'hsqldb', version:'2.5.1'
3234
// schema validation issue with testImplementation group: 'xerces', name: 'xercesImpl', version:'2.12.0'
3335
testImplementation group: 'org.opengis.cite.xerces', name: 'xercesImpl-xsd11', version:'2.12-beta-r1667115'
36+
3437
compileOnly group: 'org.jdom', name: 'jdom2', version:'2.0.6'
3538
compileOnly group: 'dom4j', name: 'dom4j', version:'1.6.1'
3639
compileOnly group: 'com.google.code.gson', name: 'gson', version:'2.8.6'

ml-development-tools/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ dependencies {
1919
testImplementation 'com.squareup.okhttp3:okhttp:4.10.0'
2020
}
2121

22+
// Added to avoid problem where processResources fails because - somehow - the plugin properties file is getting
23+
// copied twice. This started occurring with the upgrade of Gradle from 6.x to 7.x.
24+
tasks.processResources {
25+
duplicatesStrategy = "exclude"
26+
}
27+
2228
task mlDevelopmentToolsJar(type: Jar, dependsOn: classes) {
2329
archivesBaseName = 'ml-development-tools'
2430
}

0 commit comments

Comments
 (0)