diff --git a/build.gradle b/build.gradle index 1115d74..fbe9538 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,9 @@ subprojects { apply plugin: "java-library" apply plugin: "maven-publish" - apply plugin: "signing" group = "com.marklogic" - version = "1.4.0" + version = "1.5.0" java { sourceCompatibility = 1.8 @@ -18,15 +17,15 @@ subprojects { mavenLocal() maven { - url "https://nexus.marklogic.com/repository/maven-snapshots/" + url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/" } } dependencies { // Forcing Spring to use logback instead of commons-logging - testImplementation "ch.qos.logback:logback-classic:1.3.5" // Not using 1.4.x yet as it requires Java 11 - testImplementation 'org.slf4j:jcl-over-slf4j:1.7.36' - testImplementation 'org.slf4j:slf4j-api:1.7.36' + testImplementation "ch.qos.logback:logback-classic:1.3.14" // Not using 1.4.x yet as it requires Java 11 + testImplementation 'org.slf4j:jcl-over-slf4j:2.0.16' + testImplementation 'org.slf4j:slf4j-api:2.0.16' } javadoc.failOnError = false diff --git a/examples/getting-started/build.gradle b/examples/getting-started/build.gradle index 0b5a45e..573adca 100644 --- a/examples/getting-started/build.gradle +++ b/examples/getting-started/build.gradle @@ -9,7 +9,7 @@ buildscript { plugins { id "net.saliman.properties" version "1.5.2" - id "com.marklogic.ml-gradle" version "4.5.2" + id "com.marklogic.ml-gradle" version "5.0.0" } repositories { diff --git a/examples/getting-started/gradle/wrapper/gradle-wrapper.jar b/examples/getting-started/gradle/wrapper/gradle-wrapper.jar index 249e583..2c35211 100644 Binary files a/examples/getting-started/gradle/wrapper/gradle-wrapper.jar and b/examples/getting-started/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/getting-started/gradle/wrapper/gradle-wrapper.properties b/examples/getting-started/gradle/wrapper/gradle-wrapper.properties index ae04661..09523c0 100644 --- a/examples/getting-started/gradle/wrapper/gradle-wrapper.properties +++ b/examples/getting-started/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/getting-started/gradlew b/examples/getting-started/gradlew index a69d9cb..f5feea6 100755 --- a/examples/getting-started/gradlew +++ b/examples/getting-started/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,12 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +134,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/examples/getting-started/gradlew.bat b/examples/getting-started/gradlew.bat index f127cfd..9b42019 100644 --- a/examples/getting-started/gradlew.bat +++ b/examples/getting-started/gradlew.bat @@ -1,91 +1,94 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/examples/test-examples/build.gradle b/examples/test-examples/build.gradle index 171afc0..573adca 100644 --- a/examples/test-examples/build.gradle +++ b/examples/test-examples/build.gradle @@ -9,7 +9,7 @@ buildscript { plugins { id "net.saliman.properties" version "1.5.2" - id "com.marklogic.ml-gradle" version "4.6.0" + id "com.marklogic.ml-gradle" version "5.0.0" } repositories { diff --git a/examples/test-examples/gradle/wrapper/gradle-wrapper.jar b/examples/test-examples/gradle/wrapper/gradle-wrapper.jar index 249e583..2c35211 100644 Binary files a/examples/test-examples/gradle/wrapper/gradle-wrapper.jar and b/examples/test-examples/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/test-examples/gradle/wrapper/gradle-wrapper.properties b/examples/test-examples/gradle/wrapper/gradle-wrapper.properties index ae04661..09523c0 100644 --- a/examples/test-examples/gradle/wrapper/gradle-wrapper.properties +++ b/examples/test-examples/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/test-examples/gradlew b/examples/test-examples/gradlew index a69d9cb..f5feea6 100755 --- a/examples/test-examples/gradlew +++ b/examples/test-examples/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,12 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +134,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/examples/test-examples/gradlew.bat b/examples/test-examples/gradlew.bat index f127cfd..9b42019 100644 --- a/examples/test-examples/gradlew.bat +++ b/examples/test-examples/gradlew.bat @@ -1,91 +1,94 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..2c35211 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fac48c..09523c0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Thu Jun 07 14:02:15 EDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip diff --git a/gradlew b/gradlew index 4453cce..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,130 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save ( ) { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,22 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -9,25 +27,29 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -35,48 +57,36 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/marklogic-junit5/build.gradle b/marklogic-junit5/build.gradle index 94ddf69..1a1dbd3 100644 --- a/marklogic-junit5/build.gradle +++ b/marklogic-junit5/build.gradle @@ -1,17 +1,12 @@ -plugins { - id "com.github.jk1.dependency-license-report" version "1.17" -} - dependencies { api project(":marklogic-unit-test-client") - api "com.marklogic:ml-javaclient-util:4.6.0" + api "com.marklogic:ml-javaclient-util:5.0.0" api "org.jdom:jdom2:2.0.6.1" - api "org.junit.jupiter:junit-jupiter:5.10.0" - api "org.springframework:spring-context:5.3.29" - api "org.springframework:spring-test:5.3.29" - api "com.fasterxml.jackson.core:jackson-databind:2.15.2" - api 'org.slf4j:slf4j-api:1.7.36' - + api "org.junit.jupiter:junit-jupiter:5.11.2" + api "org.springframework:spring-context:5.3.39" + api "org.springframework:spring-test:5.3.39" + api "com.fasterxml.jackson.core:jackson-databind:2.17.2" + api 'org.slf4j:slf4j-api:2.0.16' implementation "jaxen:jaxen:2.0.0" } @@ -19,40 +14,18 @@ test { useJUnitPlatform() } -task sourcesJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier "javadoc" - from javadoc -} - -artifacts { - archives javadocJar, sourcesJar -} -signing { - sign configurations.archives -} - -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)) - } +// Publishing setup - see https://docs.gradle.org/current/userguide/publishing_setup.html . +java { + withJavadocJar() + withSourcesJar() } publishing { publications { mainJava(MavenPublication) { + groupId = group + version = version + from components.java pom { name = "${group}:${project.name}" description = "Supports testing MarkLogic applications" @@ -79,15 +52,11 @@ publishing { developerConnection = "scm:git@github.com:marklogic-community/${project.name}.git" } } - from components.java - artifact sourcesJar - artifact javadocJar } } repositories { maven { if (project.hasProperty("mavenUser")) { - name = "nexus" credentials { username mavenUser password mavenPassword diff --git a/marklogic-junit5/examples/simple-ml-gradle/build.gradle b/marklogic-junit5/examples/simple-ml-gradle/build.gradle index 2a49e1e..6be328d 100644 --- a/marklogic-junit5/examples/simple-ml-gradle/build.gradle +++ b/marklogic-junit5/examples/simple-ml-gradle/build.gradle @@ -1,6 +1,6 @@ plugins { id "net.saliman.properties" version "1.5.1" - id "com.marklogic.ml-gradle" version "4.4.0" + id "com.marklogic.ml-gradle" version "5.0.0" id "java-library" } @@ -16,11 +16,11 @@ repositories { dependencies { mlBundle "com.marklogic:marklogic-unit-test-modules:1.4.0" - api "com.marklogic:marklogic-client-api:6.3.0" + api "com.marklogic:marklogic-client-api:7.0.0" testImplementation "com.marklogic:marklogic-junit5:1.4.0" // Forcing Spring to use logback instead of commons-logging - testImplementation "ch.qos.logback:logback-classic:1.3.5" - testImplementation "org.slf4j:jcl-over-slf4j:1.7.36" + testImplementation "ch.qos.logback:logback-classic:1.3.14" + testImplementation "org.slf4j:jcl-over-slf4j:2.0.16" } diff --git a/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.jar b/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.jar index f6b961f..2c35211 100644 Binary files a/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.jar and b/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.properties b/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.properties index 549d844..09523c0 100644 --- a/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.properties +++ b/marklogic-junit5/examples/simple-ml-gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/marklogic-junit5/examples/simple-ml-gradle/gradlew b/marklogic-junit5/examples/simple-ml-gradle/gradlew index cccdd3d..f5feea6 100755 --- a/marklogic-junit5/examples/simple-ml-gradle/gradlew +++ b/marklogic-junit5/examples/simple-ml-gradle/gradlew @@ -1,78 +1,130 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/marklogic-junit5/examples/simple-ml-gradle/gradlew.bat b/marklogic-junit5/examples/simple-ml-gradle/gradlew.bat index f955316..9b42019 100644 --- a/marklogic-junit5/examples/simple-ml-gradle/gradlew.bat +++ b/marklogic-junit5/examples/simple-ml-gradle/gradlew.bat @@ -1,84 +1,94 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/marklogic-junit5/pom.xml b/marklogic-junit5/pom.xml index 24b7a9a..b4b70c8 100644 --- a/marklogic-junit5/pom.xml +++ b/marklogic-junit5/pom.xml @@ -46,7 +46,7 @@ It is not intended to be used to build this project. com.marklogic ml-javaclient-util - 4.6.0 + 5.0.0 compile @@ -58,31 +58,31 @@ It is not intended to be used to build this project. org.junit.jupiter junit-jupiter - 5.10.0 + 5.11.2 compile org.springframework spring-context - 5.3.29 + 5.3.39 compile org.springframework spring-test - 5.3.29 + 5.3.39 compile com.fasterxml.jackson.core jackson-databind - 2.15.2 + 2.17.2 compile org.slf4j slf4j-api - 1.7.36 + 2.0.16 compile diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java index 04e3b5f..4f9de76 100644 --- a/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java @@ -12,9 +12,11 @@ import com.marklogic.test.unit.TestModule; import com.marklogic.test.unit.TestResult; import com.marklogic.test.unit.TestSuiteResult; +import org.jdom2.Namespace; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; +import java.util.ArrayList; import java.util.List; /** @@ -29,7 +31,7 @@ * This class depends on a DatabaseClient, and how that is provided must be defined by the subclass. *

*/ -public abstract class AbstractMarkLogicTest extends LoggingObject { +public abstract class AbstractMarkLogicTest extends LoggingObject implements MarkLogicVersionSupplier { /** * Subclass must define how a connection is made to (presumably) the test database. @@ -38,6 +40,16 @@ public abstract class AbstractMarkLogicTest extends LoggingObject { */ protected abstract DatabaseClient getDatabaseClient(); + /** + * @return + * @since 1.5.0 + */ + @Override + public MarkLogicVersion getMarkLogicVersion() { + String version = getDatabaseClient().newServerEval().javascript("xdmp.version()").evalAs(String.class); + return new MarkLogicVersion(version); + } + /** * Before a test method runs, delete all of the documents in the database that match the query defined by * getJavascriptForDeletingDocumentsBeforeTestRuns. @@ -74,6 +86,15 @@ protected XmlNode parseXml(String xml) { return new XmlNode(xml, getNamespaceProvider().getNamespaces()); } + /** + * Read an XML document without making any assertions on its collections. + * + * @since 1.5.0 + */ + protected XmlNode readXmlDocument(String uri) { + return readXmlDocument(uri, (String[]) null); + } + /** * Read the XML document at the given URI and return an XmlNode for making assertions on the contents of the XML. * @@ -89,6 +110,23 @@ protected XmlNode readXmlDocument(String uri, String... expectedCollections) { return new XmlNode(uri, xml, getNamespaceProvider().getNamespaces()); } + /** + * Read an XML document with the given namespaces included in the returned {@code XmlNode}. + * + * @since 1.5.0 + */ + protected XmlNode readXmlDocument(String uri, Namespace... namespaces) { + String xml = getDatabaseClient().newXMLDocumentManager().read(uri, new StringHandle()).get(); + List list = new ArrayList<>(); + for (Namespace ns : getNamespaceProvider().getNamespaces()) { + list.add(ns); + } + for (Namespace ns : namespaces) { + list.add(ns); + } + return new XmlNode(uri, xml, list.toArray(new Namespace[0])); + } + /** * Read the JSON document at the given URI and return a JsonNode. * diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java new file mode 100644 index 0000000..b6fe4b3 --- /dev/null +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2024 MarkLogic Corporation. All Rights Reserved. + */ +package com.marklogic.junit5; + +/** + * Parses a MarkLogic version string - i.e. from xdmp.version() - into its major, minor, and patch values. + */ +public class MarkLogicVersion { + + // For semver releases, which started with MarkLogic 11. + private final static String SEMVER_PATTERN = "^[0-9]+\\.[0-9]+\\.[0-9]+"; + private final static String NIGHTLY_SEMVER_PATTERN = "^[0-9]+\\.[0-9]+\\.[0-9]{8}"; + + // For non-semver releases, such as MarkLogic 10 and earlier.. + private final static String MAJOR_WITH_MINOR_PATTERN = "^.*-(.+)$"; + private final static String VERSION_WITH_PATCH_PATTERN = "^.*-(.+)\\..*"; + private final static String NIGHTLY_BUILD_PATTERN = "[^-]+-(\\d{4})(\\d{2})(\\d{2})"; + + private final int major; + private final Integer minor; + private final Integer patch; + private final boolean nightly; + + public MarkLogicVersion(String version) { + if (version.matches(NIGHTLY_SEMVER_PATTERN)) { + String[] tokens = version.split("\\."); + this.major = Integer.parseInt(tokens[0]); + this.minor = Integer.parseInt(tokens[1]); + this.patch = null; + this.nightly = true; + } else if (version.matches(SEMVER_PATTERN)) { + String[] tokens = version.split("\\."); + this.major = Integer.parseInt(tokens[0]); + this.minor = Integer.parseInt(tokens[1]); + this.patch = Integer.parseInt(tokens[2]); + this.nightly = false; + } else { + this.major = Integer.parseInt(version.replaceAll("([^.]+)\\..*", "$1")); + if (version.matches(NIGHTLY_BUILD_PATTERN)) { + this.minor = null; + this.patch = null; + this.nightly = true; + } else { + this.nightly = false; + if (version.matches(MAJOR_WITH_MINOR_PATTERN)) { + if (version.matches(VERSION_WITH_PATCH_PATTERN)) { + this.minor = Integer.parseInt(version.replaceAll(VERSION_WITH_PATCH_PATTERN, "$1")); + this.patch = Integer.parseInt(version.replaceAll("^.*-(.+)\\.(.*)", "$2")); + } else { + this.minor = Integer.parseInt(version.replaceAll(MAJOR_WITH_MINOR_PATTERN, "$1")); + this.patch = null; + } + } else { + this.minor = null; + this.patch = null; + } + } + } + } + + public int getMajor() { + return major; + } + + public Integer getMinor() { + return minor; + } + + public Integer getPatch() { + return patch; + } + + public boolean isNightly() { + return nightly; + } +} diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersionSupplier.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersionSupplier.java new file mode 100644 index 0000000..a1debfe --- /dev/null +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersionSupplier.java @@ -0,0 +1,12 @@ +/* + * Copyright © 2024 MarkLogic Corporation. All Rights Reserved. + */ +package com.marklogic.junit5; + +/** + * @since 1.5.0 + */ +public interface MarkLogicVersionSupplier { + + MarkLogicVersion getMarkLogicVersion(); +} diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/RequiresMarkLogic11.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/RequiresMarkLogic11.java new file mode 100644 index 0000000..2dfd9e6 --- /dev/null +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/RequiresMarkLogic11.java @@ -0,0 +1,21 @@ +/* + * Copyright © 2024 MarkLogic Corporation. All Rights Reserved. + */ +package com.marklogic.junit5; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; + +/** + * Convenience for tests that require MarkLogic 11 or higher. + * + * @since 1.5.0 + */ +public class RequiresMarkLogic11 extends VersionExecutionCondition { + + @Override + protected ConditionEvaluationResult evaluateVersion(MarkLogicVersion version) { + return version.getMajor() >= 10 ? + ConditionEvaluationResult.enabled("MarkLogic is version 11 or higher.") : + ConditionEvaluationResult.disabled("MarkLogic is version 10 or lower."); + } +} diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/RequiresMarkLogic12.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/RequiresMarkLogic12.java new file mode 100644 index 0000000..81e4de8 --- /dev/null +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/RequiresMarkLogic12.java @@ -0,0 +1,21 @@ +/* + * Copyright © 2024 MarkLogic Corporation. All Rights Reserved. + */ +package com.marklogic.junit5; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; + +/** + * Convenience for tests that require MarkLogic 12 or higher. + * + * @since 1.5.0 + */ +public class RequiresMarkLogic12 extends VersionExecutionCondition { + + @Override + protected ConditionEvaluationResult evaluateVersion(MarkLogicVersion version) { + return version.getMajor() >= 12 ? + ConditionEvaluationResult.enabled("MarkLogic is version 12 or higher.") : + ConditionEvaluationResult.disabled("MarkLogic is version 11 or lower."); + } +} diff --git a/marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java b/marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java new file mode 100644 index 0000000..949ead2 --- /dev/null +++ b/marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2024 MarkLogic Corporation. All Rights Reserved. + */ +package com.marklogic.junit5; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +import java.util.Optional; + +/** + * Simplifies implementing an execution condition based on the MarkLogic version. Can only be used on classes that + * implement the {@code HasMarkLogicVersion} interface. + * + * @since 1.5.0 + */ +public abstract class VersionExecutionCondition implements ExecutionCondition { + + private static MarkLogicVersion markLogicVersion; + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + if (markLogicVersion == null) { + Optional testInstance = context.getTestInstance(); + if (!testInstance.isPresent()) { + throw new RuntimeException(getClass() + " can only be used when a test instance is present."); + } + if (!(testInstance.get() instanceof MarkLogicVersionSupplier)) { + throw new RuntimeException(testInstance.getClass() + " must implement " + MarkLogicVersionSupplier.class.getName()); + } + markLogicVersion = ((MarkLogicVersionSupplier) context.getTestInstance().get()).getMarkLogicVersion(); + } + return evaluateVersion(markLogicVersion); + } + + protected abstract ConditionEvaluationResult evaluateVersion(MarkLogicVersion version); +} diff --git a/marklogic-junit5/src/test/java/com/marklogic/junit5/MarkLogicVersionTest.java b/marklogic-junit5/src/test/java/com/marklogic/junit5/MarkLogicVersionTest.java new file mode 100644 index 0000000..ebd2f90 --- /dev/null +++ b/marklogic-junit5/src/test/java/com/marklogic/junit5/MarkLogicVersionTest.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2024 MarkLogic Corporation. All Rights Reserved. + */ +package com.marklogic.junit5; + +import com.marklogic.junit5.spring.AbstractSpringMarkLogicTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Verifies the logic in the {@code MarkLogicVersion} class. + */ +class MarkLogicVersionTest extends AbstractSpringMarkLogicTest { + + private MarkLogicVersion version; + + @Test + void semver() { + version = make("11.3.1"); + assertEquals(11, version.getMajor()); + assertEquals(3, version.getMinor()); + assertEquals(1, version.getPatch()); + assertFalse(version.isNightly()); + } + + @Test + void nightlySemver() { + version = make("12.0.20241022"); + assertEquals(12, version.getMajor()); + assertEquals(0, version.getMinor()); + assertNull(version.getPatch()); + assertTrue(version.isNightly()); + } + + @Test + void minor10() { + version = make("10.0-11"); + assertEquals(10, version.getMajor()); + assertEquals(11, version.getMinor()); + assertNull(version.getPatch()); + assertFalse(version.isNightly()); + } + + @Test + void patch10() { + version = make("10.0-11.1"); + assertEquals(10, version.getMajor()); + assertEquals(11, version.getMinor()); + assertEquals(1, version.getPatch()); + assertFalse(version.isNightly()); + } + + @Test + void nightly10() { + version = make("10.0-20241022"); + assertEquals(10, version.getMajor()); + assertNull(version.getMinor()); + assertNull(version.getPatch()); + assertTrue(version.isNightly()); + } + + private MarkLogicVersion make(String versionString) { + return new MarkLogicVersion(versionString); + } +} diff --git a/marklogic-junit5/src/test/java/com/marklogic/junit5/RequiresMarkLogicVersionTest.java b/marklogic-junit5/src/test/java/com/marklogic/junit5/RequiresMarkLogicVersionTest.java new file mode 100644 index 0000000..dab2334 --- /dev/null +++ b/marklogic-junit5/src/test/java/com/marklogic/junit5/RequiresMarkLogicVersionTest.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2024 MarkLogic Corporation. All Rights Reserved. + */ +package com.marklogic.junit5; + +import com.marklogic.junit5.spring.AbstractSpringMarkLogicTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * This is a smoke test to ensure the two concrete conditions do not cause an error. + */ +class RequiresMarkLogicVersionTest extends AbstractSpringMarkLogicTest { + + @Test + @ExtendWith(RequiresMarkLogic12.class) + void requires12() { + assertNotNull(getMarkLogicVersion()); + } + + @Test + @ExtendWith(RequiresMarkLogic11.class) + void requires11() { + assertNotNull(getMarkLogicVersion()); + } +} diff --git a/marklogic-junit5/src/test/java/com/marklogic/junit5/spring/XmlNodeTest.java b/marklogic-junit5/src/test/java/com/marklogic/junit5/spring/XmlNodeTest.java index c11a0eb..621e4af 100644 --- a/marklogic-junit5/src/test/java/com/marklogic/junit5/spring/XmlNodeTest.java +++ b/marklogic-junit5/src/test/java/com/marklogic/junit5/spring/XmlNodeTest.java @@ -4,22 +4,30 @@ import com.marklogic.junit5.MarkLogicNamespaceProvider; import com.marklogic.junit5.NamespaceProvider; import com.marklogic.junit5.XmlNode; +import org.jdom2.Namespace; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class XmlNodeTest extends AbstractSpringMarkLogicTest { +class XmlNodeTest extends AbstractSpringMarkLogicTest { + + private static final String TEST_URI = "/test/1.xml"; + + private boolean useCustomNamespaceProvider = true; @Override protected NamespaceProvider getNamespaceProvider() { - return new MarkLogicNamespaceProvider("m", "org:example"); + return useCustomNamespaceProvider ? + new MarkLogicNamespaceProvider("m", "org:example") : + super.getNamespaceProvider(); } - @Test - public void test() { - getDatabaseClient().newXMLDocumentManager().write("/test/1.xml", + @BeforeEach + void setup() { + getDatabaseClient().newXMLDocumentManager().write(TEST_URI, new StringHandle("" + "" + "red" + @@ -27,10 +35,13 @@ public void test() { "medium" + "hello" + "")); + } - XmlNode xml = readXmlDocument("/test/1.xml"); + @Test + public void test() { + XmlNode xml = readXmlDocument(TEST_URI); - assertEquals("/test/1.xml", xml.getUri()); + assertEquals(TEST_URI, xml.getUri()); xml.assertElementValue("/m:message/m:size", "medium"); assertEquals("medium", xml.getElementValue("/m:message/m:size")); assertEquals("true", xml.getAttributeValue("/m:message/m:color[. = 'red']", "important")); @@ -47,4 +58,11 @@ public void test() { xml.prettyPrint(); assertNotNull(xml.getPrettyXml()); } + + @Test + void readWithNamespaces() { + useCustomNamespaceProvider = false; + XmlNode xml = readXmlDocument(TEST_URI, Namespace.getNamespace("m", "org:example")); + xml.assertElementValue("/m:message/m:size", "medium"); + } } diff --git a/marklogic-unit-test-client/build.gradle b/marklogic-unit-test-client/build.gradle index 444551a..16bc670 100644 --- a/marklogic-unit-test-client/build.gradle +++ b/marklogic-unit-test-client/build.gradle @@ -1,56 +1,31 @@ plugins { // ml-gradle is used for deploying a test application so that this project itself can be tested - id "com.marklogic.ml-gradle" version "4.5.2" - - // Used to generate a license report - id "com.github.jk1.dependency-license-report" version "1.17" + id "com.marklogic.ml-gradle" version "5.0.0" } dependencies { - api "com.marklogic:marklogic-client-api:6.3.0" - implementation "org.slf4j:slf4j-api:1.7.36" + api "com.marklogic:marklogic-client-api:7.0.0" + implementation "org.slf4j:slf4j-api:2.0.16" - testImplementation "org.junit.jupiter:junit-jupiter:5.10.0" + testImplementation "org.junit.jupiter:junit-jupiter:5.11.2" } test { useJUnitPlatform() } -task sourcesJar(type: Jar, dependsOn: classes) { - classifier 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier "javadoc" - from javadoc -} - -artifacts { - archives javadocJar, sourcesJar -} -signing { - sign configurations.archives -} - -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)) - } +// Publishing setup - see https://docs.gradle.org/current/userguide/publishing_setup.html . +java { + withJavadocJar() + withSourcesJar() } publishing { publications { mainJava(MavenPublication) { + groupId = group + version = version + from components.java pom { name = "${group}:${project.name}" description = "Supports testing MarkLogic applications" @@ -77,15 +52,11 @@ publishing { developerConnection = "scm:git@github.com:marklogic-community/${project.name}.git" } } - from components.java - artifact sourcesJar - artifact javadocJar } } repositories { maven { if (project.hasProperty("mavenUser")) { - name = "nexus" credentials { username mavenUser password mavenPassword diff --git a/marklogic-unit-test-client/pom.xml b/marklogic-unit-test-client/pom.xml index f96ddfe..0951b61 100644 --- a/marklogic-unit-test-client/pom.xml +++ b/marklogic-unit-test-client/pom.xml @@ -40,13 +40,13 @@ It is not intended to be used to build this project. com.marklogic marklogic-client-api - 6.3.0 + 7.0.0 compile org.slf4j slf4j-api - 1.7.36 + 2.0.16 runtime diff --git a/marklogic-unit-test-modules/build.gradle b/marklogic-unit-test-modules/build.gradle index 94bc00e..1642ba3 100644 --- a/marklogic-unit-test-modules/build.gradle +++ b/marklogic-unit-test-modules/build.gradle @@ -1,34 +1,31 @@ // Defines a configuration for the MarkLogic modules; used by the modulesJar task below configurations { - modules + modules } task sourcesJar(type: Jar) { - description = "Create a jar of the modules to meet Maven Central's requirements for publishing" - classifier "sources" - from "src/main/ml-modules" - destinationDir file("build/libs") + description = "Create a jar of the modules to meet Maven Central's requirements for publishing" + archiveClassifier = "sources" + from "src/main/ml-modules" + destinationDirectory = file("build/libs") } task javadocJar(type: Jar, dependsOn: javadoc) { - classifier "javadoc" + archiveClassifier = "javadoc" from javadoc } task modulesJar(type: Jar) { - description = "Jar up the marklogic-unit-test MarkLogic modules into a package that can be published" - from("src/main/ml-modules") { - into("marklogic-unit-test-modules/ml-modules") - } - destinationDir file("build/libs") - baseName "marklogic-unit-test-modules" + description = "Jar up the marklogic-unit-test MarkLogic modules into a package that can be published" + from("src/main/ml-modules") { + into("marklogic-unit-test-modules/ml-modules") + } + destinationDirectory = file("build/libs") + archiveBaseName = "marklogic-unit-test-modules" } artifacts { - archives sourcesJar, javadocJar, modulesJar -} -signing { - sign configurations.archives + archives sourcesJar, javadocJar, modulesJar } publishing { @@ -68,7 +65,6 @@ publishing { repositories { maven { if (project.hasProperty("mavenUser")) { - name = "nexus" credentials { username mavenUser password mavenPassword