diff --git a/build.gradle b/build.gradle index 06c8f3ac3..89d038dbd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,9 @@ -// Copyright © 2024 MarkLogic Corporation. All Rights Reserved. - -// We need the properties plugin to work on both marklogic-client-api and test-app. The 'plugins' Gradle syntax can't be -// used for that. So we have to add the properties plugin to the buildscript classpath and then apply the properties -// plugin via subprojects below. -buildscript { - repositories { - maven { - url = "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "net.saliman:gradle-properties-plugin:1.5.2" - } -} +/* + * Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. + */ subprojects { - apply plugin: "net.saliman.properties" - apply plugin: 'java' + apply plugin: 'java-library' tasks.withType(JavaCompile) { options.encoding = 'UTF-8' @@ -46,6 +33,11 @@ subprojects { } test { + useJUnitPlatform() + testLogging { + events = ['started', 'passed', 'skipped', 'failed'] + exceptionFormat = 'full' + } systemProperty "file.encoding", "UTF-8" systemProperty "javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl" } diff --git a/examples/build.gradle b/examples/build.gradle index 896cc6e92..3e123799c 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -1,8 +1,6 @@ -// Copyright © 2025 MarkLogic Corporation. All Rights Reserved. - -plugins { - id "java-library" -} +/* + * Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. + */ dependencies { implementation project(':marklogic-client-api') diff --git a/examples/src/main/java/com/marklogic/client/example/cookbook/README.md b/examples/src/main/java/com/marklogic/client/example/cookbook/README.md deleted file mode 100644 index f47296fd9..000000000 --- a/examples/src/main/java/com/marklogic/client/example/cookbook/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Using Cookbook Examples - -The most important use of cookbook examples is reading the source code. You -can do this on [github](https://github.com/marklogic/java-client-api) or on -your machine once you've cloned the code from github. - -To run the examples, first edit the -[Example.properties](../../../../../../resources/Example.properties) file in the -distribution to specify the connection parameters for your server. Most -Cookbook examples have a main method, so they can be run from the command-line -like so: - - java -cp $CLASSPATH com.marklogic.client.example.cookbook.DocumentWrite - -This, of course, requires that you have all necessary dependencies in the env -variable $CLASSPATH. You can get the classpath for your machine by executing the the following gradle task - - ./gradlew printClasspath - -# Testing Cookbook Examples - -Most cookbook examples pass their unit test if they run without error. First -edit the [Example.properties](../../../../../../resources/Example.properties) file -in the distribution to specify the connection parameters for your server. Then -run `./gradlew test` while specifying the unit test you want to run, for example: - - ./gradlew java-client-api:test -Dtest.single=DocumentWriteTest - -The above command runs the DocumentWriteTest unit test in java-client-api sub project. - -# Creating a Cookbook Example - -We encourage community-contributed cookbook examples! Make sure you follow -the guidelines in [CONTRIBUTING.md](../../../../../../../../CONTRIBUTING.md) -when you submit a pull request. Each cookbook example should be runnable from -the command-line, so it should have a static `main` method. The approach in -the code should come as close as possible to production code (code one would -reasonably expect to use in a production application), while remaining as -simple as possible to facilitate grokking for newbies to the Java Client API. -It should have helpful comments throughout, including javadocs since it will -show up in the published javadocs. It should be added to -[AllCookbookExamples.java](https://github.com/marklogic/java-client-api/blob/master/marklogic-client-api/src/main/java/com/marklogic/client/example/cookbook/AllCookbookExamples.java) -in order of recommended examples for developers to review. - -It should have a unit test added to -[this package](https://github.com/marklogic/java-client-api/tree/master/marklogic-client-api/src/test/java/com/marklogic/client/test/example/cookbook). -The unit test can test whatever is needed, however most cookbook unit tests -just run the class and consider it success if no errors are thrown. Some -cookbook examples, such as SSLClientCreator and KerberosClientCreator cannot be -included in unit tests because the unit tests require a server configured with -digest authentication and those tests require a different authentication -scheme. Any cookbook examples not included in unit tests run the risk of -breaking without anyone noticing--hence we have unit tests whenever possible. diff --git a/marklogic-client-api-functionaltests/build.gradle b/marklogic-client-api-functionaltests/build.gradle index 39d866ac0..cc78be9d8 100755 --- a/marklogic-client-api-functionaltests/build.gradle +++ b/marklogic-client-api-functionaltests/build.gradle @@ -3,13 +3,9 @@ */ test { - useJUnitPlatform() - testLogging{ - events 'started','passed', 'skipped' - } - // For use in testing TestDatabaseClientKerberosFromFile - systemProperty "keytabFile", System.getProperty("keytabFile") - systemProperty "principal", System.getProperty("principal") + // For use in testing TestDatabaseClientKerberosFromFile + systemProperty "keytabFile", System.getProperty("keytabFile") + systemProperty "principal", System.getProperty("principal") systemProperty "TEST_USE_REVERSE_PROXY_SERVER", testUseReverseProxyServer } @@ -43,34 +39,34 @@ dependencies { tasks.register("runFragileTests", Test) { useJUnitPlatform() - description = "These are called 'fragile' because they'll pass when run by themselves, but when run as part of the " + - "full suite, there seem to be one or more other fast functional tests that run before them and cause some of " + - "their test methods to break. The Jenkinsfile thus calls these first before running the other functional " + - "tests." - include "com/marklogic/client/fastfunctest/TestQueryOptionBuilder.class" - include "com/marklogic/client/fastfunctest/TestRawCombinedQuery.class" - include "com/marklogic/client/fastfunctest/TestRawStructuredQuery.class" + description = "These are called 'fragile' because they'll pass when run by themselves, but when run as part of the " + + "full suite, there seem to be one or more other fast functional tests that run before them and cause some of " + + "their test methods to break. The Jenkinsfile thus calls these first before running the other functional " + + "tests." + include "com/marklogic/client/fastfunctest/TestQueryOptionBuilder.class" + include "com/marklogic/client/fastfunctest/TestRawCombinedQuery.class" + include "com/marklogic/client/fastfunctest/TestRawStructuredQuery.class" } tasks.register("runFastFunctionalTests", Test) { useJUnitPlatform() - description = "Run all fast functional tests that don't setup/teardown custom app servers / databases" - include "com/marklogic/client/fastfunctest/**" - // Exclude the "fragile" ones - exclude "com/marklogic/client/fastfunctest/TestQueryOptionBuilder.class" - exclude "com/marklogic/client/fastfunctest/TestRawCombinedQuery.class" - exclude "com/marklogic/client/fastfunctest/TestRawStructuredQuery.class" + description = "Run all fast functional tests that don't setup/teardown custom app servers / databases" + include "com/marklogic/client/fastfunctest/**" + // Exclude the "fragile" ones + exclude "com/marklogic/client/fastfunctest/TestQueryOptionBuilder.class" + exclude "com/marklogic/client/fastfunctest/TestRawCombinedQuery.class" + exclude "com/marklogic/client/fastfunctest/TestRawStructuredQuery.class" } tasks.register("runSlowFunctionalTests", Test) { useJUnitPlatform() - description = "Run slow functional tests; i.e. those that setup/teardown custom app servers / databases" - include "com/marklogic/client/datamovement/functionaltests/**" - include "com/marklogic/client/functionaltest/**" + description = "Run slow functional tests; i.e. those that setup/teardown custom app servers / databases" + include "com/marklogic/client/datamovement/functionaltests/**" + include "com/marklogic/client/functionaltest/**" } tasks.register("runFunctionalTests") { - dependsOn(runFragileTests, runFastFunctionalTests, runSlowFunctionalTests) + dependsOn(runFragileTests, runFastFunctionalTests, runSlowFunctionalTests) } runFastFunctionalTests.mustRunAfter runFragileTests runSlowFunctionalTests.mustRunAfter runFastFunctionalTests diff --git a/marklogic-client-api/build.gradle b/marklogic-client-api/build.gradle index 8f7b84bc7..40a2a0dc4 100644 --- a/marklogic-client-api/build.gradle +++ b/marklogic-client-api/build.gradle @@ -3,14 +3,9 @@ */ plugins { - id 'java-library' id 'maven-publish' } -group = 'com.marklogic' - -description = "The official MarkLogic Java client API." - dependencies { // Using the latest version now that the 8.0.0 release requires Java 17. // This is now an implementation dependency as opposed to an api dependency in 7.x and earlier. @@ -51,7 +46,7 @@ dependencies { testImplementation 'org.apache.commons:commons-lang3:3.19.0' // Allows talking to the Manage API. - testImplementation ("com.marklogic:ml-app-deployer:6.0.1") { + testImplementation("com.marklogic:ml-app-deployer:6.0.1") { exclude module: "marklogic-client-api" } @@ -92,143 +87,102 @@ test { systemProperty "TEST_USE_REVERSE_PROXY_SERVER", testUseReverseProxyServer } -task sourcesJar(type: Jar) { - archiveClassifier = 'sources' - exclude ('property', '*.xsd', '*.xjb') - from sourceSets.main.allSource -} - -javadoc { - maxMemory="6000m" - options.overview = "src/main/javadoc/overview.html" - options.windowTitle = "$rootProject.describedName $rootProject.version" - options.docTitle = "$rootProject.describedName $rootProject.version" - options.bottom = "Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved." - options.links = [ 'http://docs.oracle.com/javase/8/docs/api/' ] - options.use = true - if (JavaVersion.current().isJava9Compatible()) { - options.addBooleanOption('html4', true) - } - exclude([ - '**/impl/**', '**/jaxb/**', '**/test/**' - ]) -// workaround for bug in options.docFilesSubDirs = true - doLast{ - copy{ - from "${projectDir}/src/main/javadoc/doc-files" - into "${buildDir}/docs/javadoc/doc-files" - } - } -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - archiveClassifier = 'javadoc' - from javadoc.destinationDir -} - -Node pomCustomizations = new NodeBuilder(). project { - name "$rootProject.describedName" - packaging 'jar' - textdescription "$project.description" - url 'https://github.com/marklogic/java-client-api' - - scm { - url 'git@github.com:marklogic/java-client-api.git' - connection 'scm:git:git@github.com:marklogic/java-client-api.git' - developerConnection 'scm:git:git@github.com:marklogic/java-client-api.git' - } - - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - - developers { - developer { - name 'MarkLogic' - email 'java-sig@marklogic.com' - organization 'MarkLogic' - organizationUrl 'https://www.marklogic.com' - } - developer { - name 'MarkLogic Github Contributors' - email 'general@developer.marklogic.com' - organization 'Github Contributors' - organizationUrl 'https://github.com/marklogic/java-client-api/graphs/contributors' - } - } -} - -publishing { - publications { - mainJava(MavenPublication) { - from components.java - - pom.withXml { - asNode().append(pomCustomizations.packaging) - asNode().append(pomCustomizations.name) - asNode().appendNode("description", pomCustomizations.textdescription.text()) - asNode().append(pomCustomizations.url) - asNode().append(pomCustomizations.licenses) - asNode().append(pomCustomizations.developers) - asNode().append(pomCustomizations.scm) - } - artifact sourcesJar - artifact javadocJar - } - } - repositories { - maven { - if(project.hasProperty("mavenUser")) { - credentials { - username mavenUser - password mavenPassword - } - } - url = publishUrl - } - } -} - -task printClassPath() { - doLast { - println sourceSets.main.runtimeClasspath.asPath+':'+sourceSets.test.runtimeClasspath.asPath - } -} - -task generatePomForDependencyGraph(dependsOn: "generatePomFileForMainJavaPublication") { - description = "Prepare for a release by making a copy of the generated pom file in the root directory so that it " + - "can enable Github's Dependency Graph feature, which does not yet support Gradle" - doLast { - def preamble = '' - def comment = "" - def fileText = file("build/publications/mainJava/pom-default.xml").getText() - file("../pom.xml").setText(fileText.replace(preamble, preamble + comment)) - } -} - -task testRows(type: Test) { +tasks.register("testRows", Test) { useJUnitPlatform() description = "Run all 'rows' tests; i.e. those exercising Optic and Optic Update functionality" include "com/marklogic/client/test/rows/**" } -task debugCloudAuth(type: JavaExec) { +tasks.register("debugCloudAuth", JavaExec) { description = "Test program for manual testing of cloud-based authentication against a Progress Data Cloud instance" - mainClass = 'com.marklogic.client.test.MarkLogicCloudAuthenticationDebugger' + mainClass = 'com.marklogic.client.test.ProgressDataCloudAuthenticationDebugger' classpath = sourceSets.test.runtimeClasspath args = [cloudHost, cloudKey, cloudBasePath] } -task runXmlSmokeTests(type: Test) { +tasks.register("runXmlSmokeTests", Test) { + useJUnitPlatform() description = "Run a bunch of XML-related tests for smoke-testing on a particular JVM" include "com/marklogic/client/test/BufferableHandleTest.class" include "com/marklogic/client/test/EvalTest.class" include "com/marklogic/client/test/HandleAsTest.class" include "com/marklogic/client/test/JAXBHandleTest.class" } + +// Publishing setup - see https://docs.gradle.org/current/userguide/publishing_setup.html . +java { + withJavadocJar() + withSourcesJar() +} + +javadoc { + maxMemory = "6000m" + options.overview = "src/main/javadoc/overview.html" + options.windowTitle = "MarkLogic Java Client API $rootProject.version" + options.docTitle = "MarkLogic Java Client API $rootProject.version" + options.bottom = "Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved." + options.use = true + exclude([ + '**/impl/**', '**/jaxb/**', '**/test/**' + ]) +// workaround for bug in options.docFilesSubDirs = true + doLast { + copy { + from "${projectDir}/src/main/javadoc/doc-files" + into "${layout.buildDirectory.get()}/docs/javadoc/doc-files" + } + } +} + +publishing { + publications { + mainJava(MavenPublication) { + from components.java + pom { + name = "${group}:${project.name}" + description = "The MarkLogic Java Client API" + packaging = "jar" + url = "https://github.com/marklogic/java-client-api" + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + developers { + developer { + id = "marklogic" + name = "MarkLogic Github Contributors" + email = "general@developer.marklogic.com" + organization = "MarkLogic" + organizationUrl = "https://www.marklogic.com" + } + } + scm { + url = "git@github.com:marklogic/java-client-api.git" + connection = "scm:git:git@github.com:marklogic/java-client-api.git" + developerConnection = "scm:git:git@github.com:marklogic/java-client-api.git" + } + } + } + } + repositories { + maven { + if (project.hasProperty("mavenUser")) { + credentials { + username = mavenUser + password = mavenPassword + } + url publishUrl + allowInsecureProtocol = true + } else { + name = "central" + url = mavenCentralUrl + credentials { + username = mavenCentralUsername + password = mavenCentralPassword + } + } + } + } +} diff --git a/marklogic-client-api/gradle.properties b/marklogic-client-api/gradle.properties new file mode 100644 index 000000000..4bee29e3b --- /dev/null +++ b/marklogic-client-api/gradle.properties @@ -0,0 +1,8 @@ +# Define these on the command line to publish to OSSRH +# See https://central.sonatype.org/publish/publish-gradle/#credentials for more information +mavenCentralUsername= +mavenCentralPassword= +mavenCentralUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ +#signing.keyId=YourKeyId +#signing.password=YourPublicKeyPassword +#signing.secretKeyRingFile=PathToYourKeyRingFile diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/test/MarkLogicCloudAuthenticationDebugger.java b/marklogic-client-api/src/test/java/com/marklogic/client/test/ProgressDataCloudAuthenticationDebugger.java similarity index 97% rename from marklogic-client-api/src/test/java/com/marklogic/client/test/MarkLogicCloudAuthenticationDebugger.java rename to marklogic-client-api/src/test/java/com/marklogic/client/test/ProgressDataCloudAuthenticationDebugger.java index b4d3c7611..e542317b6 100644 --- a/marklogic-client-api/src/test/java/com/marklogic/client/test/MarkLogicCloudAuthenticationDebugger.java +++ b/marklogic-client-api/src/test/java/com/marklogic/client/test/ProgressDataCloudAuthenticationDebugger.java @@ -16,7 +16,7 @@ * "localhost" as the cloud host, "username:password" (often "admin:the admin password") as the apiKey, and * "local/manage" as the basePath. */ -public class MarkLogicCloudAuthenticationDebugger { +public class ProgressDataCloudAuthenticationDebugger { public static void main(String[] args) throws Exception { String cloudHost = args[0]; diff --git a/test-app/build.gradle b/test-app/build.gradle index c7f8a1072..a06a500b5 100644 --- a/test-app/build.gradle +++ b/test-app/build.gradle @@ -1,6 +1,10 @@ +/* + * Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. + */ + plugins { + id "net.saliman.properties" version "1.5.2" id 'com.marklogic.ml-gradle' version '6.0.1' - id 'java' id "com.github.psxpaul.execfork" version "0.2.2" } @@ -22,9 +26,9 @@ tasks.register("runReverseProxyServer", com.github.psxpaul.task.JavaExecFork) { "directly to MarkLogic" classpath = sourceSets.main.runtimeClasspath main = "com.marklogic.client.test.ReverseProxyServer" - workingDir = "$buildDir" - standardOutput = file("$buildDir/reverse-proxy.log") - errorOutput = file("$buildDir/reverse-proxy-error.log") + workingDir = "${layout.buildDirectory.get()}" + standardOutput = file("${layout.buildDirectory.get()}/reverse-proxy.log") + errorOutput = file("${layout.buildDirectory.get()}/reverse-proxy-error.log") } tasks.register("runBlockingReverseProxyServer", JavaExec) {