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
  • h

    holgerbrandl

    11/16/2017, 2:54 PM
    “that” == the special template?
    i
    • 2
    • 1
  • a

    apatrida

    11/19/2017, 1:02 PM
    https://youtrack.jetbrains.com/issue/KT-21338
    g
    s
    • 3
    • 3
  • i

    ilya.chernikov

    11/20/2017, 12:29 PM
    @apatrida Sorry, seems we messed up things while migrating to gradle, at least with json and jna. I believe that jetbrains.annotations was in the old one too. (BTW, what are the problems with the latter?) I’ll try to figure out how to fix it asap.
    a
    • 2
    • 3
  • a

    apatrida

    11/21/2017, 12:57 AM
    @holgerbrandl releases above that may affect you ^^
    h
    • 2
    • 2
  • t

    tlaukkan

    11/21/2017, 8:13 PM
    Hi, does kotlin REPL have a way to safely sandbox an enduser provided script. For example set what variables are available for the script and which functions/classes etc are available? Or should this be done with keplin?
    h
    a
    • 3
    • 14
  • k

    katien

    11/21/2017, 10:54 PM
    downgraded to Java 8, fixed the issue. Thanks for pointing me in the right direction @mkobit
    m
    • 2
    • 1
  • i

    irus

    12/07/2017, 9:08 AM
    @ilya.chernikov Because of fatjat (kotlin-compiler) I have a lot of issues with IDE when using kotlin-script-util with kotlinx.coroutines. Is it possible to stop using fat jar or at least use custom class loader as it done in spring boot?
    i
    c
    p
    • 4
    • 11
  • m

    mkobit

    01/24/2018, 2:32 AM
    has anybody built a way to hot reload a running repl?
    i
    • 2
    • 6
  • k

    kenkyee

    02/03/2018, 3:30 PM
    Error I get is: com.beust.klaxon.KlaxonException: Don't know how to convert description,duration,isGeneralEvent,isPublished,name,roomIds,startTime,updatedAt,updatedBy
    s
    g
    • 3
    • 4
  • t

    tradunsky

    02/20/2018, 8:24 PM
    Hi everyone, A quick question: is it possible to make my own engine based on KotlinJsr223JvmScriptEngineBase to use given classloader for its results?
    i
    • 2
    • 1
  • d

    dector

    03/06/2018, 12:24 PM
    Hi. Is this right place to ask questions about kscript?
    :yes: 4
    h
    • 2
    • 1
  • c

    cedric

    03/06/2018, 9:18 PM
    Never mind, figured it out
    c
    j
    • 3
    • 5
  • c

    cedric

    03/07/2018, 5:16 AM
    Calling
    engine.eval()
    on a small script is taking over six seconds, consistently. This looks crazy to me, is there any way to at least turn on some incremental compilation from the engine?
    i
    • 2
    • 4
  • c

    cedric

    03/07/2018, 6:01 AM
    @jkbbwr FYI this is what I'm playing with: https://github.com/cbeust/konfig
    o
    i
    j
    • 4
    • 4
  • s

    Sola

    03/20/2018, 11:05 PM
    why I can't use
    return
    in
    kts
    scripts?
    g
    o
    • 3
    • 8
  • b

    bsideup

    03/24/2018, 1:12 PM
    Hi! Is it possible to enforce script to use only Kotlin’s Stdlib and avoid any Java/JS/Native classes? (While keeping JVM as a target)
    i
    a
    • 3
    • 6
  • g

    Gary Tierney

    04/04/2018, 10:40 PM
    and it seems like I can just do:
    mkdir -p 'META-INF/kotlin/script/templates' && touch META-INF/kotlin/script/templates/my.package.ScriptTemplateClass
    i
    • 2
    • 12
  • s

    SrSouza

    04/07/2018, 2:39 PM
    Hi @ilya.chernikov, i can use the experimental new API for scripting now? what artifacts i need use? i'm using the older version of script, the Script Definition Template and the artifact org.jetbrains.kotlin:kotlin-script-runtime. How i make IntelliJ resolve the script file?
    i
    • 2
    • 2
  • m

    mplacona

    04/14/2018, 9:35 PM
    hey, trying to dynamically evaluate scripts on a Kotlin file and doing:
    val engine = ScriptEngineManager().getEngineByExtension("kts")
    Always returns
    null
    . Anyone has any ideas why?
    c
    • 2
    • 3
  • g

    gildor

    04/20/2018, 3:27 PM
    Is there any news/propоsals/keep about implementation details of upcoming Kotlin scripting dependencies management?
    o
    i
    g
    • 4
    • 7
  • s

    SrSouza

    05/09/2018, 12:07 AM
    @ilya.chernikov have any plan on the future make a plugin for Atom to work with Scripting support?
    i
    • 2
    • 1
  • n

    nekoinemo

    05/20/2018, 7:11 PM
    Hi. Is there currently any way to make IDE "see" certain properties/functions as being available in script inside .kts file? To elaborate - when script is run with JSR-223, it will have
    val bindings: Bindings
    available in its context. However, when editing a .kts file there doesn't seem to be obvious way to inform IDE about that, short of writing
    val bindings: Bindings = SimpleBindings()
    at the beginning of the file and commenting it out before compiling.
    g
    i
    s
    • 4
    • 8
  • g

    Gary Tierney

    05/29/2018, 11:20 AM
    @ilya.chernikov should we expect to see an updated KEEP in time for 1.2.50's official release? Working on some small example docs of my own at the moment.
    i
    • 2
    • 4
  • s

    sdeleuze

    05/29/2018, 3:37 PM
    Or is there a way to precompile kts file with the regular Gradle compiler (like kt files) in order to make the compiler optional and use it just for advanced use cases (dynamic or remote kts loading) ?
    g
    i
    • 3
    • 19
  • h

    holgerbrandl

    06/06/2018, 7:44 AM
    Hi @nastelaz, I somehow was under the impression that running scripts against project dependencies was fixed for 1.2.50+. But when running with 1.2.50-eap-62-IJ2018.1-1 it still seems broken (see screenshot). I guess the corresponding ticket is https://youtrack.jetbrains.com/issue/KT-11618 . Am I using the wrong version of the plugin?
    n
    • 2
    • 9
  • i

    ilya.chernikov

    06/13/2018, 9:29 PM
    The release 1.2.50 with new experimental scripting support is out, and the KEEP (https://github.com/Kotlin/KEEP/blob/scripting/proposals/scripting-support.md) is updated too, reflecting now the approach taken and the implementation state. Any feedback will be highly appreciated.
    ❤️ 1
    👍 6
    m
    r
    k
    • 4
    • 6
  • k

    karelpeeters

    06/13/2018, 10:01 PM
    This might be a dumb question, but how does it actually work behind the scenes? The proposal contains a lot of details of how to use it, the returned interfaces etc but what actually happens at runtime on the different platforms?
    i
    • 2
    • 3
  • d

    deviant

    06/18/2018, 3:28 PM
    https://github.com/holgerbrandl/kscript this lib allows to use
    //DEPS
    syntax to declare dependencies. is there such feature in kotlin compiler?
    🙂 1
    h
    • 2
    • 1
  • i

    irus

    06/23/2018, 1:38 PM
    Any way to get script absolute path? Like $0 in bash
    o
    • 2
    • 5
  • s

    sdeleuze

    07/03/2018, 8:26 AM
    @ilya.chernikov I am trying to leverage new scripting support in Spring Fu, but I can't make it work like I need. At some point you said that
    *.kts
    files will be compiled automatically. I have a
    src/main/resources/application.kts
    file that is defining
    val foo = ...
    and I would like to access
    foo
    from my
    src/main/kotlin
    source code. Is that use case supported? Does it require specific configuration?
    i
    • 2
    • 20
Powered by Linen
Title
s

sdeleuze

07/03/2018, 8:26 AM
@ilya.chernikov I am trying to leverage new scripting support in Spring Fu, but I can't make it work like I need. At some point you said that
*.kts
files will be compiled automatically. I have a
src/main/resources/application.kts
file that is defining
val foo = ...
and I would like to access
foo
from my
src/main/kotlin
source code. Is that use case supported? Does it require specific configuration?
i

ilya.chernikov

07/03/2018, 9:00 AM
Hi @sdeleuze First you probably need to put script into source roots, they are not compiled automatically from resources. And then to be able to access script properties and functions statically from other sources, you’ll need changes that will come with 1.2.60 (the planned EAP next week will most likely contain everything needed). With the 1.2.50 the only way is to use reflection, like:
val scriptClass = Class.forName("Application")
val ctor = scriptClass.getConstructor() // the params depend on your definition
...
s

sdeleuze

07/03/2018, 9:01 AM
Ok I will wait for
1.2.60
EAP next week then
Any chance you could provide an easy way to configure
*.kts
compilation from resources? The point of app configuration is to be separated from source code and I would like it to be optionaly externaliable.
So putting it in resources like we do for
application.properties
would be really nice
My goal is to get it compiled by default with the huge compiler dep
And optionnaly support dynalic evauationb at startup if te compiler dep is here
In such case the kts file will be outside of the JAR
i

ilya.chernikov

07/03/2018, 9:16 AM
This to my mind contradicts to the goal of having scripts to be statically resolvable on the compilation time. So, to my mind, either you want it to be part of the compilation - in this case you should put it to the place where it could be picked up by the compiler that compiles your other sources, or you want it dynamically compiled on the runtime and then you add the compiler to your dependencies and using provided infrastructure write a host the does what you want. Which case are you aiming at?
So, you can compile it from resources on runtime, we do not have ready-made helpers that will do it automatically, but it should be quite easy to write. If this is your case, I can try to bring some sample code, if you like.
s

sdeleuze

07/03/2018, 12:16 PM
Ok make sense. Yes I would like to update my dynamic configuratin module (currently based on the JSR API) to the new scripting support. See https://github.com/spring-projects/spring-fu/blob/master/modules/dynamic-configuration/. Any example of the new API would help.
Also any tips that could allow to limit the size of the dependencies and the startup time (like bytecode caching for n+1 runs) would help.
i

ilya.chernikov

07/03/2018, 12:54 PM
Ok, I’ll try to come up with some sample in the next few days. (I need to finish the changes to the 1.2.60 first though.)
s

sdeleuze

07/03/2018, 2:09 PM
Thanks
i

ilya.chernikov

07/09/2018, 4:15 PM
Hi @sdeleuze I tried to make a good example for the case of your configuration module, but unfortunately there is at least one limitation that make it impossible now - the regular scripts don’t have automatically calculated results. Only for REPL the last expression is returned from the evaluation as a result, and JSR223 API is based on the REPL. For the regular scripts the result of the
eval
call is the script class instance. Since you’re using the result returned from the script engine, I think it would be easier if you’ll continue to use JSR223 for now.
The problem itself is quite likely will be addressed in one of the following releases, and then you’ll be able to switch, if needed.
s

sdeleuze

07/10/2018, 3:09 PM
Ok thanks, please let me know when this will be fixed.
@ilya.chernikov Hey, any update on that topic? Should I keep using JSR 223 or is there anything new I should use?
i

ilya.chernikov

08/29/2018, 12:56 PM
Hi @sdeleuze, Unfortunately the issue with the return value is still unresolved. I plan to come back to it soon after release of 1.3. And about the same time I plan to assemble some compilation cache example. Then I’ll be hopefully ready to make an example for your case.
s

sdeleuze

08/29/2018, 12:56 PM
Ok
Thanks for the feedback
View count: 1