Eugen Martynov
03/05/2023, 2:37 PMephemient
03/05/2023, 2:39 PMEugen Martynov
03/05/2023, 2:40 PMmbonnin
03/05/2023, 2:40 PMkotlinx-serialization-json
without the compiler plugin. It's not as type safe but for scripts, it's often "good enough"Eugen Martynov
03/05/2023, 2:41 PMmbonnin
03/05/2023, 2:41 PM"{}".parseToJsonElement()
XMLNode
itemEugen Martynov
03/05/2023, 2:42 PMmbonnin
03/05/2023, 2:42 PMephemient
03/05/2023, 2:42 PMmbonnin
03/05/2023, 2:42 PMEugen Martynov
03/05/2023, 2:42 PMmbonnin
03/05/2023, 2:43 PMephemient
03/05/2023, 2:44 PMmbonnin
03/05/2023, 2:44 PMephemient
03/05/2023, 2:45 PMmbonnin
03/05/2023, 2:45 PMjavax.
ephemient
03/05/2023, 2:47 PMmbonnin
03/05/2023, 2:57 PMVampire
03/05/2023, 3:25 PMEugen Martynov
03/05/2023, 4:00 PMmbonnin
03/05/2023, 4:03 PMEugen Martynov
03/05/2023, 4:03 PMilya.chernikov
03/06/2023, 8:02 AMYou just cannot define new serializable objects that have default serilalizers provided by the compiler plugin as you cannot right now apply the compiler plugin.I'm not sure I understand, what is missing. There are two tests in the Kotlin repo that run this script - https://github.com/JetBrains/kotlin/blob/1.8.20/libraries/tools/kotlin-main-kts-test/testData/hello-kotlinx-serialization.main.kts - which uses plugin to generate serializers. You can add the plugin either via CLI, if cli compiler is used, or via compiler configuration.
Vampire
03/06/2023, 11:07 AMkotlinc
explicitly, or call the script from a bash script or similar, or call the script programmatically. But there is no way to make it work with calling ./hello-kotlinx-serialization.main.kts
. See the Ticket @ephemient linked above.
Note: the shebang hack is not appropriate for general usage. You either require a non-standard environment variable or an absolute path, and more important using more than one argument in the shebang line must be avoided for general usage, it is undefined and not portable and will behave majority different on different systems.ephemient
03/06/2023, 1:49 PM#!/bin/sh
//bin/true<<.
/*
.
# any shell script goes here
kotlin "$0" "$@"
exit $?
*/
// any Kotlin script goes here
println("Hello, world!")
where you can put an arbitrarily complex shell script in there that Kotlin will skip overVampire
03/06/2023, 3:37 PM.
as end of comment marker that confused me and that it does not work properly in Git Bash on Windows. 😄
There the //bin/true
does not work and needs quite some time, probably because it searches for a computer called bin
ephemient
03/06/2023, 4:04 PM#!/bin/sh
""":""" /*
kotlin "$0" "$@"
exit $?
*/
println("Hello, world!")
this would also work, using shell built-insVampire
03/06/2023, 4:05 PM@file:DependsOn
that is now preceded by a String literalephemient
03/06/2023, 4:09 PMVampire
03/06/2023, 4:09 PM#!/bin/sh
///bin/true <<EOC
/*
EOC
kotlinc ...
exit $?
*/
...
ephemient
03/06/2023, 4:13 PMVampire
03/06/2023, 4:13 PMmy-cool-tool
that is a main.kts script 🙂Paul Woitaschek
03/24/2023, 6:51 PMEugen Martynov
03/24/2023, 7:13 PMVampire
03/24/2023, 7:49 PMephemient
03/24/2023, 10:31 PMVampire
03/25/2023, 1:43 AMephemient
03/25/2023, 1:54 AMVampire
03/25/2023, 2:00 AMephemient
03/25/2023, 2:02 AMVampire
03/25/2023, 4:05 AMPaul Woitaschek
03/25/2023, 6:01 AMVampire
03/25/2023, 1:14 PMEugen Martynov
03/25/2023, 1:47 PMVampire
03/25/2023, 2:05 PM