diff options
| author | ruki <[email protected]> | 2025-02-25 17:07:10 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-02-25 17:07:10 +0800 |
| commit | e789f102f3963a471c94e6da4df1ad70adfa8f9f (patch) | |
| tree | 48f8961deb103b7152fdac18dd8761955c303d0e /tests/projects | |
| parent | fdca3b2904d158ab22f402f647fb9c34eaf2e587 (diff) | |
| parent | 87693d5c7c360b3218032bc2bff4253a27ad0425 (diff) | |
Merge pull request #6170 from xmake-io/kotlin
Add kotlin native package support
Diffstat (limited to 'tests/projects')
4 files changed, 54 insertions, 0 deletions
diff --git a/tests/projects/kotlin-native/package/cli-parser/src/main.kt b/tests/projects/kotlin-native/package/cli-parser/src/main.kt new file mode 100644 index 000000000..dae11c45c --- /dev/null +++ b/tests/projects/kotlin-native/package/cli-parser/src/main.kt @@ -0,0 +1,10 @@ +import kotlinx.cli.ArgParser +import kotlinx.cli.ArgType +import kotlinx.cli.default + +fun main(args: Array<String>) { + val parser = ArgParser("example") + val name by parser.option(ArgType.String, shortName = "n", description = "Your name").default("World") + parser.parse(args) + println("Hello, $name!") +} diff --git a/tests/projects/kotlin-native/package/cli-parser/xmake.lua b/tests/projects/kotlin-native/package/cli-parser/xmake.lua new file mode 100644 index 000000000..f2cfdac2b --- /dev/null +++ b/tests/projects/kotlin-native/package/cli-parser/xmake.lua @@ -0,0 +1,10 @@ +add_rules("mode.debug", "mode.release") + +add_requires("kotlin-native") +add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-cli 0.3.6", {alias = "kotlinx-cli"}) + +target("test") + set_kind("binary") + add_files("src/*.kt") + add_packages("kotlinx-cli") + set_toolchains("@kotlin-native") diff --git a/tests/projects/kotlin-native/package/json/src/main.kt b/tests/projects/kotlin-native/package/json/src/main.kt new file mode 100644 index 000000000..ec15ce26d --- /dev/null +++ b/tests/projects/kotlin-native/package/json/src/main.kt @@ -0,0 +1,23 @@ +import kotlinx.serialization.Serializable +import kotlinx.serialization.encodeToString +import kotlinx.serialization.json.Json + +@Serializable +private data class Message( + val topic: String, + val content: String, +) + +private val PrettyPrintJson = Json { + prettyPrint = true +} + +fun main() { + val message = Message( + topic = "Kotlin/Native", + content = "Hello!" + ) + println(PrettyPrintJson.encodeToString(message)) +} + + diff --git a/tests/projects/kotlin-native/package/json/xmake.lua b/tests/projects/kotlin-native/package/json/xmake.lua new file mode 100644 index 000000000..2f085de15 --- /dev/null +++ b/tests/projects/kotlin-native/package/json/xmake.lua @@ -0,0 +1,11 @@ +add_rules("mode.debug", "mode.release") + +add_requires("kotlin-native") +add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-serialization-json 1.8.0", {alias = "json"}) +add_requires("kotlin-native::org.jetbrains.kotlinx:kotlinx-serialization-core 1.8.0", {alias = "core"}) + +target("test") + set_kind("binary") + add_files("src/*.kt") + add_packages("json", "core") + set_toolchains("@kotlin-native") |
