diff --git a/.github/workflows/TEST.yml b/.github/workflows/TEST.yml index dfa7307..6d6d86d 100644 --- a/.github/workflows/TEST.yml +++ b/.github/workflows/TEST.yml @@ -27,7 +27,7 @@ env: CI: true JAVA_VERSION: 17 - JAVA_DISTRIBUTION: zulu + JAVA_DISTRIBUTION: temurin jobs: test: @@ -35,32 +35,33 @@ jobs: #fail-fast: true # Once working, comment this matrix: include: - - { outputKey: testMacosIos, os: macos-13, testTask: jvmTest macosX64Test iosX64Test, buildTasks: publishMacosArm64PublicationToMavenLocal } + - { outputKey: testMacosIos, os: macos-latest, testTask: jvmTest macosArm64Test iosSimulatorArm64Test, buildTasks: publishMacosX64PublicationToMavenLocal } - { outputKey: testJsAndroid, os: ubuntu-latest, testTask: "wasmBrowserTest", buildTasks: "jsBrowserTest jsDenoTest", enableAndroid: true } - - { outputKey: testLinux, os: ubuntu-latest, testTask: apiCheck jvmTest linuxX64Test, precompileTask: compileTestKotlinJvm, e2e: true } - - { outputKey: testWindows, os: windows-latest, testTask: jvmTest mingwX64Test jsDenoTest, precompileTask: compileTestKotlinJvm, enableCodecov: true } + - { outputKey: testLinux, os: ubuntu-latest, testTask: apiCheck jvmTest linuxX64Test, precompileTask: compileTestKotlinJvm, enableCodecov: true, e2e: true } + - { outputKey: testWindows, os: windows-latest, testTask: jvmTest mingwX64Test jsDenoTest, precompileTask: compileTestKotlinJvm } #if: ${{ needs.changes.outputs[matrix.outputKey] == 'true' }} - timeout-minutes: 30 + timeout-minutes: 60 runs-on: ${{ matrix.os }} steps: - { uses: actions/checkout@v4 } - { name: Use Node.js 20.x, uses: actions/setup-node@v4, with: { node-version: 20.x } } - { name: Setup Deno, uses: denoland/setup-deno@v1, with: { deno-version: "1.44.4" } } - - { name: Replace gradle wrapper, run: "sed 's/-all/-bin/g' gradle/wrapper/gradle-wrapper.properties > gradle/wrapper/gradle-wrapper.properties.bak; cp gradle/wrapper/gradle-wrapper.properties.bak gradle/wrapper/gradle-wrapper.properties" } - - { name: Set up JDK, uses: actions/setup-java@v4, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } } - - { name: Prepare Gradle, uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 } # https://github.com/gradle/actions/releases/tag/v3.5.0 + - { name: Set up JDK, uses: actions/setup-java@v4, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}", cache: 'gradle' } } + #- { name: Prepare Gradle, uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 } # https://github.com/gradle/actions/releases/tag/v4.0.0 + - { name: "Cache Kotlin/Native .konan folder", uses: actions/cache@v4, with: { path: "~/.konan", key: "${{ runner.os }}-konan", restore-keys: "${{ runner.os }}-konan" } } - { name: Start gradle, run: ./gradlew } - - { if: "${{ matrix.precompileTask }}", name: "Building ${{ matrix.precompileTask }} classes", run: "./gradlew --no-configuration-cache --stacktrace --build-cache ${{ matrix.precompileTask }}" } - - { if: "${{ matrix.enableCodecov }}", name: "Upload coverage reports to Codecov", uses: "codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673", with: { token: "${{ secrets.CODECOV_TOKEN }}" } } # https://github.com/codecov/codecov-action/releases/tag/v4.5.0 - - { if: "${{ matrix.testTask }}", name: "Run ${{ matrix.testTask }} tests", run: "./gradlew --no-configuration-cache --build-cache ${{ matrix.testTask }}" } - - { if: "${{ matrix.buildTasks }}", name: "Run ${{ matrix.buildTasks }}", run: "./gradlew --no-configuration-cache --build-cache ${{ matrix.buildTasks }}" } + - { if: "${{ matrix.precompileTask }}", name: "Building ${{ matrix.precompileTask }} classes", run: "./gradlew --stacktrace ${{ matrix.precompileTask }}" } + - { if: "${{ matrix.testTask }}", name: "Run ${{ matrix.testTask }} tests", run: "./gradlew ${{ matrix.testTask }}" } + - { if: "${{ matrix.buildTasks }}", name: "Run ${{ matrix.buildTasks }}", run: "./gradlew ${{ matrix.buildTasks }}" } - name: Enable KVM if: "${{ matrix.enableAndroid }}" run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - - { name: "Run Android Tests", if: "${{ matrix.enableAndroid }}", uses: reactivecircus/android-emulator-runner@v2, with: { "api-level": 21, "script": "./gradlew --no-configuration-cache --build-cache connectedCheck lintDebug" } } + - { name: "Run Android Tests", if: "${{ matrix.enableAndroid }}", uses: reactivecircus/android-emulator-runner@v2, with: { "api-level": 21, "script": "./gradlew connectedCheck lintDebug" } } - { name: Archive Test Results, if: failure(), uses: actions/upload-artifact@v4, with: { name: "test-results-${{ matrix.outputKey }}", retention-days: 21, path: "**/build/reports", if-no-files-found: ignore } } - - { if: "${{ matrix.e2e }}", name: Publish to maven local, run: ./gradlew --no-configuration-cache --build-cache publishJvmLocal publishKotlinMultiplatformPublicationToMavenLocal } - - { name: Code coverage, run: ./gradlew --build-cache koverXmlReport } + - { if: "${{ matrix.e2e }}", name: Publish to maven local, run: ./gradlew publishJvmLocal publishKotlinMultiplatformPublicationToMavenLocal } + - { if: "${{ matrix.enableCodecov }}", name: Code coverage, run: ./gradlew koverXmlReport } + - { if: "${{ matrix.enableCodecov }}", name: "Upload coverage reports to Codecov", uses: "codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673", with: { token: "${{ secrets.CODECOV_TOKEN }}" } } # https://github.com/codecov/codecov-action/releases/tag/v4.5.0 + - { name: Stop daemon, run: ./gradlew --stop } diff --git a/build.gradle.kts b/build.gradle.kts index 2a1b898..4c9156a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,11 +15,12 @@ import java.util.* import java.util.concurrent.* plugins { - kotlin("multiplatform") version "2.0.0" + kotlin("multiplatform") version "2.0.10" id("com.android.library") version "8.2.2" id("org.jetbrains.kotlinx.kover") version "0.8.3" apply false id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.16.2" id("org.jetbrains.dokka") version "1.9.20" + //id("org.ysb33r.ivypot") version "1.0.0" `maven-publish` signing } @@ -34,10 +35,10 @@ var REAL_VERSION = System.getenv("FORCED_VERSION") //val REAL_VERSION = System.getenv("FORCED_VERSION") ?: "999.0.0.999" -//val JVM_TARGET = JvmTarget.JVM_1_8 -//val JDK_VERSION = org.gradle.api.JavaVersion.VERSION_1_8 -val JVM_TARGET = JvmTarget.JVM_11 -val JDK_VERSION = org.gradle.api.JavaVersion.VERSION_11 +val JVM_TARGET = JvmTarget.JVM_1_8 +val JDK_VERSION = org.gradle.api.JavaVersion.VERSION_1_8 +//val JVM_TARGET = JvmTarget.JVM_11 +//val JDK_VERSION = org.gradle.api.JavaVersion.VERSION_11 val GROUP = "com.soywiz" kotlin { @@ -72,12 +73,6 @@ allprojects { } } - kotlin { - androidTarget { - this.compilerOptions.jvmTarget.set(JvmTarget.JVM_17) - } - } - android { compileOptions { sourceCompatibility = JDK_VERSION diff --git a/gradle.properties b/gradle.properties index 8708fae..890f988 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,9 +4,12 @@ kotlin.daemon.jvmargs=-Xmx4g #org.gradle.jvmargs=-Xmx2800M -Dkotlin.daemon.jvm.options="-Xmx2800M" -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.daemon=true org.gradle.parallel=true -#org.gradle.configuration-cache=true -#org.gradle.unsafe.configuration-cache-problems=warn + +org.gradle.unsafe.configuration-cache=true +org.gradle.unsafe.configuration-cache-problems=warn #org.gradle.configureondemand=true +org.gradle.caching=true + kotlin.native.ignoreDisabledTargets=true kotlin.mpp.enableCInteropCommonization=true kotlin.mpp.applyDefaultHierarchyTemplate=false @@ -17,3 +20,6 @@ systemProp.org.gradle.internal.http.connectionTimeout=160000 systemProp.org.gradle.internal.http.socketTimeout=160000 systemProp.org.gradle.internal.repository.max.retries=16 systemProp.org.gradle.internal.repository.initial.backoff=500 + +# ./gradlew -q javaToolchains +org.gradle.java.installations.auto-download=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a7..e644113 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 bb6c191..9355b41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cb..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ 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. @@ -141,7 +145,7 @@ 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=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # 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, 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. +# 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/gradlew.bat b/gradlew.bat index 93e3f59..25da30d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ 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. +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 @@ -57,11 +57,11 @@ 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. +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 diff --git a/korlibs-io/module.yaml b/korlibs-io/module.yaml index 488fd96..bbb8202 100644 --- a/korlibs-io/module.yaml +++ b/korlibs-io/module.yaml @@ -34,6 +34,4 @@ dependencies: test-dependencies: - org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0-RC - #- org.mozilla:rhino:1.7.15 - - org.openjdk.nashorn:nashorn-core:15.4 - com.soywiz:korlibs-time:6.0.0 diff --git a/korlibs-io/test/korlibs/io/vfs/ResourcesVfsTest.kt b/korlibs-io/test/korlibs/io/vfs/ResourcesVfsTest.kt index 2ac3cbf..f1071fa 100644 --- a/korlibs-io/test/korlibs/io/vfs/ResourcesVfsTest.kt +++ b/korlibs-io/test/korlibs/io/vfs/ResourcesVfsTest.kt @@ -1,17 +1,21 @@ package korlibs.io.vfs -import korlibs.memory.* -import korlibs.io.async.suspendTest -import korlibs.io.file.baseName -import korlibs.io.file.extensionLC -import korlibs.io.file.std.resourcesVfs +import korlibs.io.async.* +import korlibs.io.file.* +import korlibs.io.file.std.* import korlibs.platform.* -import kotlinx.coroutines.flow.filter -import kotlinx.coroutines.flow.toList -import kotlin.test.Test -import kotlin.test.assertEquals +import kotlinx.coroutines.flow.* +import kotlin.test.* class ResourcesVfsTest { + @Test + fun test() = suspendTest { + assertEquals( + "HELLO", + resourcesVfs["resource.txt"].readAll().decodeToString() + ) + } + @Test fun name() = suspendTest({ Platform.isJvm }) { //println("[A]") diff --git a/korlibs-io/test@js/korlibs/io/lang/JsEvalTest.kt b/korlibs-io/test@js/korlibs/io/lang/JsEvalTest.kt deleted file mode 100644 index 9167d1a..0000000 --- a/korlibs-io/test@js/korlibs/io/lang/JsEvalTest.kt +++ /dev/null @@ -1,19 +0,0 @@ -package korlibs.io.lang - -import korlibs.memory.* -import korlibs.io.* -import korlibs.io.async.* -import korlibs.platform.* -import kotlin.test.* - -class JsEvalTest { - @Test - fun test() = suspendTest { - assertEquals(true, Platform.isJs) - assertEquals(true, JSEval.available) - assertEquals(32, JSEval("return a ** b;", "a" to 2, "b" to 5)) - assertEquals(32, JSEval.expr("a ** b", "a" to 2, "b" to 5)) - assertEquals("world2", JSEval.expr("hello + 2", "hello" to "world")) - assertEquals(jsGlobal, JSEval.globalThis) - } -} diff --git a/korlibs-io/test@jvm/korlibs/io/lang/JvmJsEvalTest.kt b/korlibs-io/test@jvm/korlibs/io/lang/JvmJsEvalTest.kt deleted file mode 100644 index 275d27e..0000000 --- a/korlibs-io/test@jvm/korlibs/io/lang/JvmJsEvalTest.kt +++ /dev/null @@ -1,19 +0,0 @@ -package korlibs.io.lang - -import korlibs.io.async.* -import javax.script.* -import kotlin.test.* - -class JvmJsEvalTest { - @Test - fun test() = suspendTest { - //println(ScriptEngineManager().engineFactories.map { it.names }) - //println(ScriptEngineManager().getEngineByName("rhino")) - //println(ScriptEngineManager().getEngineByName("js")) - assertEquals(true, JSEval.available) - assertEquals(10.0, JSEval("return a * b;", "a" to 2, "b" to 5)) - assertEquals(10.0, JSEval.expr("a * b", "a" to 2, "b" to 5)) - assertEquals("world2", JSEval.expr("hello + 2", "hello" to "world")) - //assertEquals(jsGlobal, JSEval.globalThis) - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index e8e9bcd..e93d65e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,6 +16,9 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0") +} for (file in rootDir.listFiles()) { if (file.isDirectory() && File(file, "module.yaml").exists()) {