https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
scripting
  • k

    kissed

    03/18/2021, 9:24 AM
    Hi! Has anyone faced to such a problem: kts scripts doesn’t highlight in Android Studio multiple script definitions are applicable for this script. KotlinSettingsScript is used
    v
    8 replies · 2 participants
  • g

    Gary Tierney

    03/22/2021, 6:35 AM
    is there a list of common reasons that the IDE would fail to load script definitions from module dependencies? I have a simple freestanding project (no Gradle, just JARs on the modules classpath) and the behavior I see is: 2021.1 EAP: resolution broken, entry not appearing under Kotin Scripting in settings under any circumstance 2020.3: resolution working intermittently, the script definition sometimes disappears from the Kotlin Scripting window and the IDE thinks my scripts are regular kotlin scripts 2019.3: consistently working discovery is setup via a file in
    META-INF/kotlin/script/templates
    as many of the other existing examples do it. I wonder if the IDE runs into some error processing my definition, but if it is that's not being made visible to me
    s
    e
    +2
    7 replies · 5 participants
  • m

    mkobit

    03/29/2021, 6:13 PM
    It doesn't look like
    @ScriptBody
    is implemented yet. It there a different way to return a value from a script to the scripting host?
    r
    2 replies · 2 participants
  • t

    Timo Drick

    04/03/2021, 1:16 PM
    Is it possible to enable compiler plugins for kts compilation. I would like to compile Compose code inside of an Kotlin application. Ideally i would like to have the code as kotlin script and than execute the script during runtime from the host program.
    m
    5 replies · 2 participants
  • d

    Dave K

    04/07/2021, 9:18 PM
    In Kotlin 1.4 scripting is it possible to include/import a script in another script? The idea is I want to write some reusable utility functions somewhere and then include them in a script I intend to actually run.
    i
    p
    7 replies · 3 participants
  • y

    yschimke

    04/09/2021, 4:51 PM
    I'm noticing with main.kts scripts, it's like driving Intellij with the handbrake on. The same changes in a .kt file are silky smooth. But I can feel the jank even scrolling when actively editing a bunch of main.kts scripts.
    i
    2 replies · 2 participants
  • u

    ushort

    04/17/2021, 12:21 AM
    Have this issue with my custom script definition. Using IJ 2020.3.3, Kotlin version 1.4.32. Appreciate any help
    e
    3 replies · 2 participants
  • s

    SrSouza

    04/19/2021, 6:32 PM
    HI folks, I want to know what is the state for the support of suspending in the script body?
    ➕ 2
    i
    2 replies · 2 participants
  • a

    Andrew Steinmetz

    04/22/2021, 1:45 AM
    I have been playing around with Kscript and was trying to figure out how to run my tests in CI on github but keep running into issues. I saw this note on the kscript user guide about testing in CI but can't seem to get this to work on Github actions and was curious if anybody had an example workflow to do this?
    l
    2 replies · 2 participants
  • s

    SrSouza

    04/23/2021, 7:30 PM
    Hi folks, there is any way to get the logging from the Script definition when running in a IntelliJ plugin? I'm using ScriptDefinitionsProvider.
    p
    5 replies · 2 participants
  • s

    SrSouza

    04/23/2021, 9:35 PM
    There is anyway to send a variable, like enviroment, from IntelliJ plugin to the script definition? like, "is running on IntelliJ" and some config that the user can set on the Plugin settings. Ex: API Token from a private repository that with this the script definition will to retrieve the dependency sources
    p
    n
    5 replies · 3 participants
  • n

    nfrankel

    05/08/2021, 7:39 AM
    👋 i was running a kotlin script (.kts) nicely on kotlin 1.4 and it breaks on 1.5 because this is on github actions the stack trace is pretty limited
    error: backend Internal error: Exception during code generation
    File being compiled: update.main.kts
    The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:54) (update.main.kts): org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during code generation
    File being compiled: update.main.kts
    The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:54)
    Error: Process completed with exit code 1.
    i searched to open a bug on kotlin youtrack but didn’t find a way 😬 if a jetbrains employee finds this message, please ping me
    i
    i
    +1
    9 replies · 4 participants
  • r

    RayeW47

    05/12/2021, 12:02 AM
    Hello, I am wondering how to set up a scripting environment so that every file with a certain extension are wrapped inside a class and has default imports with autocomplete in the ide. I have not been able to find adequate resources for something like this online and have only at most been able to load kts files manually.
    i
    4 replies · 2 participants
  • b

    Big Chungus

    06/03/2021, 5:40 PM
    How do I clear kotlinc scripts cache?
    m
    j
    +1
    12 replies · 4 participants
  • b

    Big Chungus

    06/04/2021, 12:52 PM
    Any idea how to get intellij to highlight my standalone .kts files? It suddently stopped doing that
    m
    i
    13 replies · 3 participants
  • n

    neugartf

    06/04/2021, 6:33 PM
    Hey 🙂 When using the
    ScriptJvmCompiler
    I’m running into a this error:
    Using old JVM backend
    java.lang.IllegalStateException: The provided plugin org.jetbrains.kotlin.samWithReceiver.SamWithReceiverComponentRegistrar is not compatible with this version of compiler
    (Script is placed in
    buildSrc
    ) Does anyone have an idea? JDK is 11.0.10 and Kotlin 1.5.10. https://scans.gradle.com/s/rdbi5m2x3g27o/failure#1
    i
    7 replies · 2 participants
  • n

    Neon

    06/05/2021, 4:00 PM
    Hello, guys. I'm trying to make something like plugins in my app. But, I got a problem with setting up context for scripts. My configuration is here - https://pastebin.com/HkaEgx2z. My script is here - https://pastebin.com/XzUx6iaB. They all in one module and pkg, but the script does not see the new context. I'll be glad If someone help! Thanks in advance!
    i
    1 reply · 2 participants
  • e

    eygraber

    06/09/2021, 5:12 PM
    Is there any way to precompile a main.kts script?
    👀 1
    d
    g
    5 replies · 3 participants
  • a

    Alex Ostrovsky

    06/10/2021, 2:11 PM
    hello all! I need to dynamically compile Kotlin code and then get the resulting .class files, I've been using kotlin-compiler-embeddable for this with KotlinCoreEnvironment and KotlinToJVMBytecodeCompiler. is that the right way to go, or is there some way to extract the class files from the Kotlin scripting API?
    ✅ 1
    👀 1
    i
    9 replies · 2 participants
  • t

    Tianyu Zhu

    06/16/2021, 3:35 PM
    If I create my own kind of kotlin scripts, e.g. with
    @KotlinScript(fileExtension = "my.kts")
    abstract class MyScript
    Presumably with some default imports and some implicit receivers, how do I get IntelliJ to help me highlight and autocomplete my file?
    b
    i
    7 replies · 3 participants
  • b

    Bmyte

    06/17/2021, 2:24 AM
    Maybe I'm missing some fundamental understanding of what .kts and KotlinScripts are or how they are supposed to work?? Are they still largely experimental?
    i
    2 replies · 2 participants
  • r

    rnett

    06/19/2021, 2:13 AM
    Is there a way to "extend" main.kts? I want to create my own script definition (compiler plugin + context), but use dependencies and imports. Dependencies is in a separate artifact, so that's easy enough to use, but is there any way to do the same for the rest of the stuff in main.kts?
    b
    i
    15 replies · 3 participants
  • p

    Piotr Krzemiński

    06/27/2021, 5:48 AM
    Hi all, I really fell in love in single-file Kotlin scripts, and I also like staying close to Kotlin-centric libraries. A problem occurs when I try to use e. g. kotlinx.serialization. See https://youtrack.jetbrains.com/issue/KT-47384. Is there any sane workaround, or a concrete plan to solve it? I created it as a bug, but it got converted to a feature request without any comment 😕
    b
    2 replies · 2 participants
  • l

    louiscad

    07/01/2021, 8:37 AM
    How can I tell the IDE to resolve Kotlin 1.5 for my
    .main.kts
    scripts? IDEA and Android Studio take the Kotlin version of the current Gradle project, while they share no Kotlin version.
    1 reply · 1 participant
  • c

    Colton Idle

    07/02/2021, 11:40 PM
    Need to write a new script. Deciding between doing it in bash, using kotlin to make a jar to execute, but I know "kotlin scripts" exists. What's the different between a kotlin script and just building a jar?
    m
    7 replies · 2 participants
  • n

    nfrankel

    07/07/2021, 9:16 AM
    i’m running a Kotlin script as part of a github action to debug, I wanted to add
    println()
    statements in different places the problem is that it doesn’t show up in the action’s log i’ve blamed github and moved to a docker container however, it doesn’t output to the standard out either, though it prints warning messages related to the classpath now, i’m wondering what is wrong
    l
    7 replies · 2 participants
  • f

    Florian Magin

    07/23/2021, 10:45 AM
    Is there some way to just pass an entire object
    obj
    as a "Binding", like wrapping the entire
    .kts
    Script I want to evaluate in a
    with  (obj){ }
    block?
    i
    19 replies · 2 participants
  • s

    SrSouza

    08/08/2021, 6:44 PM
    Is possible to use KSP in scripting?
    i
    1 reply · 2 participants
  • e

    Egor

    08/17/2021, 9:24 AM
    We recently upgraded to 1.5 which uses IR by default, as a result our scripts code broke. I can not paste the code here, but basically next code worked fine in 1.4.x and is broken in 1.5:
    //========================== Script 1 =============================
    @file:Import("script2.cp.kts")
    fun doMain() {
      doSomeDummyWork()
    }
    //========================== script2.cp.kts =============================
    fun doSomeDummyWork(): Int {
      return 42
    }
    The error message:
    The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
    	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
    	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
    ...
    Caused by: java.lang.RuntimeException: Exception while generating code for:
    FUN name:doMain visibility:public modality:FINAL <> ($this:<root>.Script1_cp) returnType:kotlin.Unit
      $this: VALUE_PARAMETER name:<this> type:<root>.Script1_cp
      BLOCK_BODY
        COMPOSITE type=kotlin.Unit origin=null
          CALL 'public final fun doSomeDummyWork (): <http://kotlin.Int|kotlin.Int> declared in <root>.Script2_cp' type=<http://kotlin.Int|kotlin.Int> origin=null
            $this: GET_VAR '<this>: <root>.Utils_cp declared in <root>.Rater_cp.<init>' type=<root>.Utils_cp origin=null
          COMPOSITE type=kotlin.Unit origin=null
    
    	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
    	at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:43)
    ...
    Caused by: java.lang.IllegalStateException: No mapping for symbol: VALUE_PARAMETER SCRIPT_IMPLICIT_RECEIVER name:<this> index:1 type:<root>.Script2_cp
    	at org.jetbrains.kotlin.backend.jvm.codegen.IrFrameMap.typeOf(irCodegenUtils.kt:64)
    	at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitGetValue(ExpressionCodegen.kt:648)
    @ilya.chernikov can you help here?
    i
    5 replies · 2 participants
  • l

    louiscad

    08/23/2021, 2:26 PM
    In case you missed it, you can now run Kotlin scripts right in GitHub Actions: https://twitter.com/Louis_CAD/status/1428326004112691200?s=19
    :kotlin-intensifies: 2
    n
    e
    5 replies · 3 participants
Powered by Linen
Title
l

louiscad

08/23/2021, 2:26 PM
In case you missed it, you can now run Kotlin scripts right in GitHub Actions: https://twitter.com/Louis_CAD/status/1428326004112691200?s=19
:kotlin-intensifies: 2
n

nfrankel

08/24/2021, 5:57 AM
additional question: what level of the language is installed? because 1.5 has issues and i explicitly install 1.4 😅 this also allows me to run the script simply as
./update.main.kts
l

louiscad

08/24/2021, 6:33 AM
1.5.21, except on Windows where they apparently installed 1.5.20. You can look into the README of the project, it links towards all the details.
👍 1
n

nfrankel

08/24/2021, 6:54 AM
thanks @louiscad (and thanks for creating the issue in the first place)
➕ 1
e

elect

09/14/2021, 10:05 AM
super nice, thanks for sharing
I wish they could offer writing Kotlin dsl as an alternative to yaml files
View count: 3