diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..1b69efd --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,55 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [ "main" ] + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Set up Java JDK 18 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '18.0.2+9' + - name: Gradle Cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ~/.gradle/native + key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle.kts') }} + - name: Build & Test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + chmod +x ./gradlew + ./gradlew dokkaHtml + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: 'build/dokka/html' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 diff --git a/build.gradle.kts b/build.gradle.kts index 70019b7..dc8e4d7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,7 @@ plugins { id("me.qoomon.git-versioning") version "6.4.3" id("com.goncalossilva.resources") version "0.4.0" id("com.github.ben-manes.versions") version "0.50.0" + id("org.jetbrains.dokka") version "1.9.10" } repositories { @@ -135,7 +136,11 @@ kotlin { } @OptIn(ExperimentalWasmDsl::class) - wasmJs() + wasmJs { + // All tests reading from files fail, because kotlinx-io + // has no Path support for WASM (yet?). + // nodejs() + } @OptIn(ExperimentalWasmDsl::class) wasmWasi() @@ -158,9 +163,6 @@ kotlin { /* Kotlin Test */ implementation(kotlin("test")) - /* Multiplatform test resources */ - implementation("com.goncalossilva:resources:0.4.0") - /* Multiplatform file access */ implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.3.0") } @@ -229,6 +231,22 @@ kotlin { macosX64Main.dependsOn(this) macosArm64Main.dependsOn(this) } + + val iosArm64Test by sourceSets.getting + val iosSimulatorArm64Test by sourceSets.getting + val macosX64Test by sourceSets.getting + val macosArm64Test by sourceSets.getting + + @Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive + val appleTest by sourceSets.creating { + + dependsOn(commonTest) + + iosArm64Test.dependsOn(this) + iosSimulatorArm64Test.dependsOn(this) + macosX64Test.dependsOn(this) + macosArm64Test.dependsOn(this) + } } // region Writing version.txt for GitHub Actions @@ -400,3 +418,12 @@ publishing { } } // endregion + +//rootProject.the().apply { +// nodeVersion = "21.0.0-v8-canary202309143a48826a08" +// nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" +//} +// +//tasks.withType().configureEach { +// args.add("--ignore-engines") +//} diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock new file mode 100644 index 0000000..618a703 --- /dev/null +++ b/kotlin-js-store/yarn.lock @@ -0,0 +1,13 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +format-util@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" + integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg== + +typescript@5.0.4: + version "5.0.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" + integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== diff --git a/src/androidUnitTest/kotlin/com/ashampoo/xmp/ResourcePath.android.kt b/src/androidUnitTest/kotlin/com/ashampoo/xmp/ResourcePath.android.kt new file mode 100644 index 0000000..a0df55f --- /dev/null +++ b/src/androidUnitTest/kotlin/com/ashampoo/xmp/ResourcePath.android.kt @@ -0,0 +1,3 @@ +package com.ashampoo.xmp + +actual fun getPathForResource(path: String): String = path diff --git a/src/appleTest/kotlin/com/ashampoo/xmp/ResourcePath.apple.kt b/src/appleTest/kotlin/com/ashampoo/xmp/ResourcePath.apple.kt new file mode 100644 index 0000000..d01e906 --- /dev/null +++ b/src/appleTest/kotlin/com/ashampoo/xmp/ResourcePath.apple.kt @@ -0,0 +1,13 @@ +package com.ashampoo.xmp + +import platform.Foundation.NSBundle + +actual fun getPathForResource(path: String): String { + + val pathForResource = NSBundle.mainBundle.pathForResource( + path.substringBeforeLast("."), + path.substringAfterLast(".") + ).toString() + + return pathForResource +} diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/PathExtensions.kt b/src/commonTest/kotlin/com/ashampoo/xmp/PathExtensions.kt new file mode 100644 index 0000000..ec2bab5 --- /dev/null +++ b/src/commonTest/kotlin/com/ashampoo/xmp/PathExtensions.kt @@ -0,0 +1,14 @@ +package com.ashampoo.xmp + +import kotlinx.io.buffered +import kotlinx.io.files.Path +import kotlinx.io.files.SystemFileSystem +import kotlinx.io.readByteArray + +@OptIn(ExperimentalStdlibApi::class) +internal fun Path.readText(): String = + SystemFileSystem + .source(this) + .buffered() + .use { it.readByteArray() } + .decodeToString() diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/ResourcePath.kt b/src/commonTest/kotlin/com/ashampoo/xmp/ResourcePath.kt new file mode 100644 index 0000000..c123492 --- /dev/null +++ b/src/commonTest/kotlin/com/ashampoo/xmp/ResourcePath.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2023 Ashampoo GmbH & Co. KG + * + * 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 + * + * http://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. + */ +package com.ashampoo.xmp + +expect fun getPathForResource(path: String): String diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt b/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt index eb9156e..9ce75db 100644 --- a/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt +++ b/src/commonTest/kotlin/com/ashampoo/xmp/RewriteXmpTest.kt @@ -1,7 +1,6 @@ package com.ashampoo.xmp import com.ashampoo.xmp.options.SerializeOptions -import com.goncalossilva.resources.Resource import kotlinx.io.buffered import kotlinx.io.files.Path import kotlinx.io.files.SystemFileSystem @@ -214,13 +213,13 @@ class RewriteXmpTest { } private fun getOriginalXmp(index: Int): String = - Resource("$RESOURCE_PATH/sample_$index.xmp").readText() + Path(getPathForResource("$RESOURCE_PATH/sample_$index.xmp")).readText() private fun getFormattedCompactXmp(index: Int): String = - Resource("$RESOURCE_PATH/sample_${index}_formatted_compact.xmp").readText() + Path(getPathForResource("$RESOURCE_PATH/sample_${index}_formatted_compact.xmp")).readText() private fun getFormattedCanonicalXmp(index: Int): String = - Resource("$RESOURCE_PATH/sample_${index}_formatted_canonical.xmp").readText() + Path(getPathForResource("$RESOURCE_PATH/sample_${index}_formatted_canonical.xmp")).readText() companion object { diff --git a/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt b/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt index 875e56a..f2773ef 100644 --- a/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt +++ b/src/commonTest/kotlin/com/ashampoo/xmp/WriteXmpTest.kt @@ -2,7 +2,6 @@ package com.ashampoo.xmp import com.ashampoo.xmp.options.PropertyOptions import com.ashampoo.xmp.options.SerializeOptions -import com.goncalossilva.resources.Resource import kotlinx.io.buffered import kotlinx.io.files.Path import kotlinx.io.files.SystemFileSystem @@ -184,7 +183,7 @@ class WriteXmpTest { } private fun getXmp(name: String): String = - Resource("$RESOURCE_PATH/$name").readText() + Path(getPathForResource("$RESOURCE_PATH/$name")).readText() companion object { private const val RESOURCE_PATH: String = "src/commonTest/resources/com/ashampoo/xmp" diff --git a/src/jvmTest/kotlin/com/ashampoo/xmp/ResourcePath.jvm.kt b/src/jvmTest/kotlin/com/ashampoo/xmp/ResourcePath.jvm.kt new file mode 100644 index 0000000..a0df55f --- /dev/null +++ b/src/jvmTest/kotlin/com/ashampoo/xmp/ResourcePath.jvm.kt @@ -0,0 +1,3 @@ +package com.ashampoo.xmp + +actual fun getPathForResource(path: String): String = path diff --git a/src/wasmJsTest/kotlin/com/ashampoo/xmp/ResourcePath.wasmJs.kt b/src/wasmJsTest/kotlin/com/ashampoo/xmp/ResourcePath.wasmJs.kt new file mode 100644 index 0000000..a0df55f --- /dev/null +++ b/src/wasmJsTest/kotlin/com/ashampoo/xmp/ResourcePath.wasmJs.kt @@ -0,0 +1,3 @@ +package com.ashampoo.xmp + +actual fun getPathForResource(path: String): String = path diff --git a/src/wasmWasiTest/kotlin/com/ashampoo/xmp/ResourcePath.wasmWasi.kt b/src/wasmWasiTest/kotlin/com/ashampoo/xmp/ResourcePath.wasmWasi.kt new file mode 100644 index 0000000..a0df55f --- /dev/null +++ b/src/wasmWasiTest/kotlin/com/ashampoo/xmp/ResourcePath.wasmWasi.kt @@ -0,0 +1,3 @@ +package com.ashampoo.xmp + +actual fun getPathForResource(path: String): String = path diff --git a/src/winTest/kotlin/com/ashampoo/xmp/ResourcePath.win.kt b/src/winTest/kotlin/com/ashampoo/xmp/ResourcePath.win.kt new file mode 100644 index 0000000..a0df55f --- /dev/null +++ b/src/winTest/kotlin/com/ashampoo/xmp/ResourcePath.win.kt @@ -0,0 +1,3 @@ +package com.ashampoo.xmp + +actual fun getPathForResource(path: String): String = path