diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 478dd7e..2c6fe25 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -9,12 +9,12 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v5 with: distribution: 'temurin' - java-version: '17' + java-version: '21' cache: 'gradle' - name: install gpg @@ -24,7 +24,7 @@ jobs: apt install -y gpg fi - - uses: crazy-max/ghaction-import-gpg@v6 + - uses: crazy-max/ghaction-import-gpg@v7 with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.GPG_PASSPHRASE }} @@ -39,22 +39,15 @@ jobs: -Psigning.gnupg.useLegacyGpg=true \ -Psigning.gnupg.keyName=${{ secrets.GPG_SIGN_KEY }} \ -Pversion=${GITHUB_REF_NAME} \ - publishToSonatype + publish - - name: close staging + - name: finalize deployment + if: ${{ !endsWith(github.ref_name, '-SNAPSHOT') }} env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} run: | - ./gradlew --no-daemon \ - -Pversion=${GITHUB_REF_NAME} \ - findSonatypeStagingRepository closeSonatypeStagingRepository - - - name: release version - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - run: | - ./gradlew --no-daemon \ - -Pversion=${GITHUB_REF_NAME} \ - findSonatypeStagingRepository releaseSonatypeStagingRepository + ENCODED=$(echo -n "${OSSRH_USERNAME}:${OSSRH_PASSWORD}" | base64) + curl --fail-with-body -X POST \ + -H "Authorization: Bearer ${ENCODED}" \ + "https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.rapatao.ruleset?publishing_type=automatic" diff --git a/README.md b/README.md index 4d487ac..516bcea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # ruleset-engine [![Maven Central](https://img.shields.io/maven-central/v/com.rapatao.ruleset/ruleset-engine.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:com.rapatao.ruleset%20AND%20a:ruleset-engine) -[![Sonatype OSS](https://img.shields.io/nexus/r/com.rapatao.ruleset/ruleset-engine?label=Sonatype%20OSS&server=https%3A%2F%2Foss.sonatype.org)](https://ossindex.sonatype.org/component/pkg:maven/com.rapatao.ruleset/ruleset-engine) Simple yet powerful rules engine that offers the flexibility of using the built-in engine and creating a custom one. @@ -109,10 +108,8 @@ printing the `result` in the default output. ### Code example ```kotlin - import com.rapatao.projects.ruleset.engine.Evaluator -import com.rapatao.projects.ruleset.engine.context.EvalEngine -import com.rapatao.projects.ruleset.engine.types.builder.equalsTo +import com.rapatao.projects.ruleset.engine.types.builder.extensions.equalsTo val rule = "item.price" equalsTo 0 val input = mapOf("item" to mapOf("price" to 0)) @@ -127,7 +124,7 @@ data class Item(val price: Double) data class Input(val item: Item) val result2 = evaluator.evaluate(rule, Input(item = Item(price = 0.0))) -println(result) // true +println(result2) // true ``` ## Expressions (Rule) @@ -217,11 +214,11 @@ operator by one implemented by the user of this library. ## Supported group operations -A grouped operation is `true` when all inner operations result in: +A grouped operation is evaluated as follows: -* `anyMatch`: any operation must be evaluated as `true` -* `allMatch`: all operations must be evaluated as `true` -* `noneMatch`: all operations must be evaluated as `false` +* `anyMatch`: at least one inner expression must evaluate to `true` +* `allMatch`: all inner expressions must evaluate to `true` +* `noneMatch`: all inner expressions must evaluate to `false` ### Examples @@ -257,21 +254,68 @@ Expression( ) ```` +## Range (between) expressions + +Range expressions can be composed using the `from`/`fromInclusive` extensions combined with `to`/`toInclusive`. + +```kotlin +import com.rapatao.projects.ruleset.engine.types.builder.extensions.from +import com.rapatao.projects.ruleset.engine.types.builder.extensions.fromInclusive + +// price > 10 AND price < 20 +"price" from 10 to 20 + +// price >= 10 AND price <= 20 +"price" fromInclusive 10 toInclusive 20 +``` + +## Failure handling + +Each `Expression` accepts an `onFailure` strategy that controls what happens when its evaluation throws (for example, +when a referenced field is missing from the input data). + +| value | behavior | +|---------|-----------------------------------------------------------------------------| +| `THROW` | (default) re-throws the underlying exception | +| `TRUE` | swallows the exception and treats the expression as `true` | +| `FALSE` | swallows the exception and treats the expression as `false` | + +The strategy can be set directly on the `Expression` constructor or applied to an existing expression via the +`ifFail` extension: + +```kotlin +import com.rapatao.projects.ruleset.engine.types.OnFailure +import com.rapatao.projects.ruleset.engine.types.builder.extensions.equalsTo +import com.rapatao.projects.ruleset.engine.types.builder.extensions.ifFail + +"item.optional.field" equalsTo 10 ifFail OnFailure.FALSE +``` + ## Expression serialization ### Jackson -All provided operations supports serialization using [Jackson](https://github.com/FasterXML/jackson) with the definition -of a Mixin. +All provided operations support serialization using [Jackson](https://github.com/FasterXML/jackson) with the definition +of a Mixin. The project currently targets Jackson 3.x (`tools.jackson` namespace). Mixin interface: `com.rapatao.projects.ruleset.jackson.ExpressionMixin` Example of usage: ```kotlin -val mapper = jacksonObjectMapper() - .setSerializationInclusion(JsonInclude.Include.NON_NULL) +import com.fasterxml.jackson.annotation.JsonInclude +import com.rapatao.projects.ruleset.engine.types.Expression +import com.rapatao.projects.ruleset.jackson.ExpressionMixin +import tools.jackson.databind.json.JsonMapper +import tools.jackson.module.kotlin.jacksonMapperBuilder +import tools.jackson.module.kotlin.readValue + +val mapper: JsonMapper = jacksonMapperBuilder() + .changeDefaultPropertyInclusion { inclusion -> + inclusion.withValueInclusion(JsonInclude.Include.NON_NULL) + } .addMixIn(Expression::class.java, ExpressionMixin::class.java) + .build() val json = "{ serialized definition }" diff --git a/build.gradle b/build.gradle index 21ffbf1..769b682 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,6 @@ plugins { id "org.jetbrains.kotlin.jvm" version "${kotlinVersion}" id "io.gitlab.arturbosch.detekt" version "${detektVersion}" id "org.jetbrains.kotlinx.kover" version "${koverVersion}" - id "io.github.gradle-nexus.publish-plugin" version "${publishPluginVersion}" id "com.github.ben-manes.versions" version "${benManerVersionsVersion}" } @@ -88,6 +87,18 @@ allprojects { } publishing { + repositories { + maven { + name = "mavenCentral" + url = version.endsWith("SNAPSHOT") + ? "https://central.sonatype.com/repository/maven-snapshots/" + : "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/" + credentials { + username = System.getenv('OSSRH_USERNAME') + password = System.getenv('OSSRH_PASSWORD') + } + } + } publications { maven(MavenPublication) { from components.java @@ -131,15 +142,6 @@ allprojects { } } -nexusPublishing { - repositories { - sonatype { - username = System.getenv('OSSRH_USERNAME') - password = System.getenv('OSSRH_PASSWORD') - } - } -} - def isNonStable = { String version -> def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) } def regex = /^[0-9,.v-]+(-r)?$/ diff --git a/gradle.properties b/gradle.properties index a319ceb..4a55e01 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ -benManerVersionsVersion=0.51.0 +benManerVersionsVersion=0.52.0 credentialsVersion=3.0 detektVersion=1.23.6 +graalvmPolyglotVersion=24.1.0 hamcrestVersion=3.0 -jacksonVersion=2.17.2 +jacksonVersion=3.1.3 jacocoVersion=0.8.7 -javaVersion=17 +javaVersion=21 +junitPlatformVersion=1.11.2 junitVersion=5.11.2 -kotlinVersion=2.0.20 -koverVersion=0.8.3 -publishPluginVersion=2.0.0 -rhinoVersion=1.7.15 -graalvmPolyglotVersion=24.1.0 +kotlinVersion=2.3.21 +koverVersion=0.9.1 +rhinoVersion=1.8.1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b9..d997cfc 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 df97d72..5dd3c01 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6..739907d 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 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. @@ -57,7 +57,7 @@ # 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 +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/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/. @@ -86,8 +86,7 @@ done # 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 +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -115,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -173,7 +171,6 @@ fi # 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" ) @@ -206,15 +203,14 @@ fi 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, +# * DEFAULT_JVM_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 \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9d21a21..e509b2d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,94 +1,93 @@ -@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 +@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 + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +: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/jackson/build.gradle b/jackson/build.gradle index de011b9..d8bed1e 100644 --- a/jackson/build.gradle +++ b/jackson/build.gradle @@ -1,8 +1,8 @@ dependencies { implementation project(":core") - implementation("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:${jacksonVersion}") + implementation("tools.jackson.core:jackson-databind:${jacksonVersion}") + implementation("tools.jackson.module:jackson-module-kotlin:${jacksonVersion}") testImplementation project(":tests") testImplementation project(":kotlin-evaluator") diff --git a/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationExamplesBuilder.kt b/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationExamplesBuilder.kt index 4110289..79add50 100644 --- a/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationExamplesBuilder.kt +++ b/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationExamplesBuilder.kt @@ -1,7 +1,6 @@ package com.rapatao.projects.ruleset.jackson import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.rapatao.projects.ruleset.engine.cases.TestData import com.rapatao.projects.ruleset.engine.evaluator.kotlin.KotlinEvaluator import com.rapatao.projects.ruleset.engine.types.Expression @@ -19,6 +18,8 @@ import com.rapatao.projects.ruleset.engine.types.builder.extensions.lessThan import com.rapatao.projects.ruleset.engine.types.builder.extensions.notEqualsTo import com.rapatao.projects.ruleset.engine.types.builder.extensions.startsWith import org.junit.jupiter.api.Test +import tools.jackson.databind.json.JsonMapper +import tools.jackson.module.kotlin.jacksonMapperBuilder import java.nio.file.Path import java.nio.file.Paths import kotlin.io.path.appendText @@ -28,9 +29,12 @@ import kotlin.io.path.writeText internal class SerializationExamplesBuilder { - private val mapper = jacksonObjectMapper() - .setSerializationInclusion(JsonInclude.Include.NON_NULL) + val mapper: JsonMapper = jacksonMapperBuilder() + .changeDefaultPropertyInclusion { inclusion -> + inclusion.withValueInclusion(JsonInclude.Include.NON_NULL) + } .addMixIn(Expression::class.java, ExpressionMixin::class.java) + .build() private val engine = KotlinEvaluator() diff --git a/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationTest.kt b/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationTest.kt index a0ad110..1b2ad6f 100644 --- a/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationTest.kt +++ b/jackson/src/test/kotlin/com/rapatao/projects/ruleset/jackson/SerializationTest.kt @@ -1,8 +1,6 @@ package com.rapatao.projects.ruleset.jackson import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import com.fasterxml.jackson.module.kotlin.readValue import com.rapatao.projects.ruleset.engine.cases.TestData import com.rapatao.projects.ruleset.engine.evaluator.kotlin.KotlinEvaluator import com.rapatao.projects.ruleset.engine.helper.Helper.compareMatcher @@ -15,12 +13,18 @@ import com.rapatao.projects.ruleset.engine.types.builder.extensions.ifFail import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.MethodSource +import tools.jackson.databind.json.JsonMapper +import tools.jackson.module.kotlin.jacksonMapperBuilder +import tools.jackson.module.kotlin.readValue class SerializationTest { - private val mapper = jacksonObjectMapper() - .setSerializationInclusion(JsonInclude.Include.NON_NULL) + val mapper: JsonMapper = jacksonMapperBuilder() + .changeDefaultPropertyInclusion { inclusion -> + inclusion.withValueInclusion(JsonInclude.Include.NON_NULL) + } .addMixIn(Expression::class.java, ExpressionMixin::class.java) + .build() companion object { @JvmStatic diff --git a/rhino-evaluator/src/main/kotlin/com/rapatao/projects/ruleset/engine/evaluator/rhino/RhinoContextFactory.kt b/rhino-evaluator/src/main/kotlin/com/rapatao/projects/ruleset/engine/evaluator/rhino/RhinoContextFactory.kt index f25ae73..48b0bdc 100644 --- a/rhino-evaluator/src/main/kotlin/com/rapatao/projects/ruleset/engine/evaluator/rhino/RhinoContextFactory.kt +++ b/rhino-evaluator/src/main/kotlin/com/rapatao/projects/ruleset/engine/evaluator/rhino/RhinoContextFactory.kt @@ -13,7 +13,7 @@ import org.mozilla.javascript.ContextFactory * @see org.mozilla.javascript.Context */ open class RhinoContextFactory( - private val optimizationLevel: Int = -1, + private val interpretedMode: Boolean = true, private val wrapJavaPrimitives: Boolean = false, private val languageVersion: Int = Context.VERSION_DEFAULT, ) : ContextFactory() { @@ -41,7 +41,7 @@ open class RhinoContextFactory( override fun makeContext(): Context { val context = super.makeContext() - context.optimizationLevel = optimizationLevel + context.isInterpretedMode = interpretedMode context.wrapFactory.isJavaPrimitiveWrap = wrapJavaPrimitives context.languageVersion = languageVersion diff --git a/tests/build.gradle b/tests/build.gradle index 5286198..801ee79 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -1,7 +1,7 @@ dependencies { implementation project(":core") - runtimeOnly("org.junit.platform:junit-platform-launcher") + runtimeOnly("org.junit.platform:junit-platform-launcher:${junitPlatformVersion}") api("org.junit.jupiter:junit-jupiter:${junitVersion}") api("org.hamcrest:hamcrest:${hamcrestVersion}") }