diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 8a95a5ed32..b524d384fc 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -70,7 +70,9 @@ jobs: java-version: 21 distribution: graalvm-community cache: gradle - - run: ./gradlew --stacktrace nativeTest + - run: echo "COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_ENV + - if: ${{ env.COMMIT_COUNT > 0 }} + run: ./gradlew --stacktrace nativeTest jmh: uses: hexagonkt/.github/.github/workflows/graalvm_gradle.yml@master diff --git a/core/README.md b/core/README.md index 340db727fe..68a8951fc6 100644 --- a/core/README.md +++ b/core/README.md @@ -30,7 +30,10 @@ application), you can import it with the following code: ``` # Package com.hexagonkt.core -JVM information and other useful utilities. +JVM information and other useful utilities. Includes basic program settings support at the [Jvm] +object (like loading and retrieving system settings). + +[Jvm]: /api/core/com.hexagonkt.core/-jvm # Package com.hexagonkt.core.logging Provides a logging management capabilities abstracting the application from logging libraries. @@ -55,3 +58,6 @@ Media types definitions and constants for default media types. # Package com.hexagonkt.core.security Cryptography and key stores utilities. + +# Package com.hexagonkt.core.text +Text utilities to allow the use of ANSI escape codes and case converting tools among other features. diff --git a/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt b/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt index a269af5da9..9f3a3711e4 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt @@ -105,14 +105,14 @@ object Jvm { } /** - * Retrieve a setting by name by looking in the JVM system properties first and in OS - * environment variables if not found. + * Retrieve a setting by name by looking in OS environment variables first and in the JVM system + * properties if not found. * * @param type Type of the requested parameter. Supported types are: boolean, int, long, float, * double and string, throw an error if other type is supplied. * @param name Name of the searched parameter, can not be blank. * @return Value of the searched parameter in the requested type, `null` if the parameter is not - * found on the JVM system properties and in OS environment variables. + * found on the OS environment variables or in JVM system properties. */ fun systemSettingOrNull(type: KClass, name: String): T? = systemSettingRaw(name).let { it.parseOrNull(type) } @@ -122,8 +122,8 @@ object Jvm { ?: error("Required '${type.simpleName}' system setting '$name' not found") /** - * Retrieve a flag (boolean parameter) by name by looking in the JVM system properties first and - * in OS environment variables if not found. + * Retrieve a flag (boolean parameter) by name by looking in OS environment variables first and + * in the JVM system properties if not found. * * @param name Name of the searched parameter, can not be blank. * @return True if the parameter is found and its value is exactly 'true', false otherwise. @@ -138,7 +138,7 @@ object Jvm { * double and string, throw an error if other type is supplied. * @param name Name of the searched parameter, can not be blank. * @return Value of the searched parameter in the requested type, `null` if the parameter is not - * found on the JVM system properties and in OS environment variables. + * found on the OS environment variables or in JVM system properties. */ inline fun systemSettingOrNull(name: String): T? = systemSettingOrNull(T::class, name) @@ -149,7 +149,7 @@ object Jvm { private fun systemSettingRaw(name: String): String? { val correctName = name.matches(systemSettingPattern) require(correctName) { "Setting name must match $systemSettingPattern" } - return System.getProperty(name, System.getenv(name)) + return System.getenv(name) ?: System.getProperty(name) } /** Operating system name ('os.name' property). If `null` throws an exception. */ diff --git a/core/src/test/kotlin/com/hexagonkt/core/HelpersTest.kt b/core/src/test/kotlin/com/hexagonkt/core/HelpersTest.kt index cca454be40..7b3197bfac 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/HelpersTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/HelpersTest.kt @@ -41,18 +41,6 @@ internal class HelpersTest { assertEquals("test", "echo test".shell().trim()) } - @Test fun `System setting works ok`() { - System.setProperty("system_property", "value") - - assert(Jvm.systemSetting("system_property") == "value") - - assert(Jvm.systemSetting("PATH").isNotEmpty()) - assertNull(Jvm.systemSettingOrNull("_not_defined_")) - - System.setProperty("PATH", "path override") - assert(Jvm.systemSetting("PATH") == "path override") - } - @Test fun `Multiple retry errors throw an exception`() { val retries = 3 try { diff --git a/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt b/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt index 3e6dc9cc75..42cdae7717 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt @@ -216,7 +216,7 @@ internal class JvmTest { assertNull(Jvm.systemSettingOrNull("_not_defined_")) System.setProperty("PATH", "path override") - assert(Jvm.systemSetting("PATH") == "path override") + assert(Jvm.systemSetting("PATH") != "path override") } private fun checkOsKind(osName: String, osKind: OsKind) { diff --git a/gradle.properties b/gradle.properties index acd240dad5..bb2318b6df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.warning.mode=all org.gradle.console=plain # Gradle -version=3.4.4 +version=3.4.5 group=com.hexagonkt description=The atoms of your platform @@ -50,19 +50,17 @@ helidonVersion=4.0.1 # http_server_servlet servletVersion=6.0.0 -jettyVersion=12.0.3 +jettyVersion=12.0.4 # rest_tools swaggerRequestValidatorVersion=2.39.0 # logging slf4jVersion=2.0.9 -logbackVersion=1.4.12 +logbackVersion=1.4.14 # serialization -# TODO -#jacksonVersion=2.16.0 -jacksonVersion=2.15.3 +jacksonVersion=2.16.0 dslJsonVersion=2.0.2 # templates_freemarker