https://kotlinlang.org logo
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
  • e

    efemoney

    02/04/2019, 5:08 AM
    Is there IDE support for
    Import
    annotations?
    So I put “log statements” (diagnostics) in the refinement handler and it turns out that kotlinscript does in fact support it … 😄 Its honestly amazing. The actual initial issue was that I defined a complex annotation sort of and so script annotation processing wasn’t able to correctly parse my annotation and was returning an
    InvalidScriptResolverAnnotation
    annotation error. Had to replace with plain string fields to get it to work like:
    // take 1:
    annotation class Res(val key: String, val code: Array<String>, val value: Array<String>) // choke 💀
    // take 2:
    annotation class Res(val key: String, vararg val entries: Entry) { // choke 💀
      annotation class Entry(val code: String, val value: String)
    }
    // take 3:
    @Repeatable
    annotation class Res(val key: String, val code: String, val value: String) // 👍
    3 is obviously the least desirable of all the options but its what works currently. I am generating kts files on the go based on annotation and they are correctly imported and referenced. Probably because I am generating directly into the src folder where the original script lives but I believe it should still work perfectly if the kts files are generated into src/resource folders (based on the
    ide.acceptedLocations
    config)
    n
    i
    • 3
    • 6
  • n

    Nikky

    02/04/2019, 9:25 PM
    btw the Script itself is a open class that extends another open class (
    ChangelogBuilder
    ) with a lot of open methods, then i evaluate the script , get the resulting object and cast it to the
    ChangelogBuilder
    i
    • 2
    • 4
  • l

    louiscad

    02/06/2019, 12:52 AM
    I just released a new version of a library successfully with all the steps involved thanks to Kotlin scripting! 🎉 🎉 🎉 I'm so happy about it I want to share that script that makes the release steps semi-automatic and less error-prone: https://github.com/LouisCAD/Splitties/blob/61e9f223219f0c1c894be77c334d826413ed720c/Releasing.kts You can see that before, it was a fully manual and error-prone 19 steps process: https://github.com/LouisCAD/Splitties/blob/61e9f223219f0c1c894be77c334d826413ed720c/RELEASING.md Maybe it can inspire you or even suit your need straightaway. Special thanks to @Nikky that got me on track to run OS commands from JDK APIs (to access things like
    git
    ).
    👍 4
    n
    j
    +2
    • 5
    • 12
  • s

    SrSouza

    02/07/2019, 6:04 PM
    Hi @ilya.chernikov, I made a fork of @Nikky Minimal Script for reproduce the error in the parse. https://github.com/DevSrSouza/MinimalScriptingExample/commit/ae95975ba2d6df895b165a73107e8fa83bb8c29e
    gradlew run_reproduce_okay
    gradlew run_reproduce_with_array
    gradlew run_reproduce_with_intarray
    n
    i
    • 3
    • 10
  • n

    Nikky

    02/08/2019, 2:30 AM
    so this is interesting:

    https://i.imgur.com/2GNrEMb.png▾

    normal execution of the script works fine, but openening in idea.. it cannot parse the annotations
    • 1
    • 3
  • k

    krotki

    02/08/2019, 6:07 PM
    Hi, just out of curiosity. If i would like to make a simple script but with external dependencies - is it plausible to load them form maven and import ?
    n
    g
    • 3
    • 7
  • n

    Nikky

    02/09/2019, 5:48 AM
    so .. the minimal scripting example has been updated.. now it also features the idea integration: https://github.com/NikkyAI/MinimalScriptingExample although firs time opening i expect it to not work until it ran
    publishToMavenLocal
    one on the
    script-host
    if anyone know how to make this work as ONE gradle project without publishing to maven and depending on that, PRs or hints are welcome
    y
    i
    • 3
    • 16
  • a

    altavir

    02/12/2019, 9:54 AM
    Is it currently possible to run a script with maven dependency in non-central repository?
    i
    • 2
    • 15
  • a

    altavir

    02/12/2019, 11:30 AM
    There seems to some kind of idea-based problem with script compillation in IDEA. I've added a
    @file:DependsOn()
    dependency (jvm flavored from mpp build) which is present it the mavenLocal, then added a
    kotlin-main-kts
    dependency to the project, then run it. That is what I got:
    Error:Kotlin: [Internal Error] kotlin.KotlinNullPointerException
    	at org.jetbrains.kotlin.incremental.TranslationResultMap.remove(IncrementalJsCache.kt:166)
    	at org.jetbrains.kotlin.incremental.IncrementalJsCache.clearCacheForRemovedClasses(IncrementalJsCache.kt:107)
    	at org.jetbrains.kotlin.jps.targets.KotlinJsModuleBuildTarget.updateCaches(KotlinJsModuleBuildTarget.kt:228)
    	at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:464)
    	at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:295)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1327)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1007)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1074)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:968)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:797)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:375)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
    	at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
    	at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
    	at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135)
    	at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:229)
    	at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
    	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:834)
    What does js incremental compilation to do with it?
    i
    • 2
    • 5
  • n

    Nikky

    02/19/2019, 1:58 PM
    so is there any big upcoming changes to scripting in the 1.3.30-eap ? anything related to idea integration? i have been trying to look through the commits but its just so much stuff unrelated to scripting
    i
    • 2
    • 1
  • b

    bram93

    02/19/2019, 3:18 PM
    Hi all, is it possible to get auto completion working on a .kts file in the root of your project folder? (Similar to build.gradle.kts file)
    i
    • 2
    • 1
  • e

    efemoney

    02/20/2019, 11:21 AM
    Hey all, In the KEEP, regarding running a standalone script https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md#standalone-scripting, where does
    /path/to/kotlin/script/runner
    in
    #! /path/to/kotlin/script/runner -some -params
    really point to?
    i
    n
    • 3
    • 7
  • l

    Lorin

    02/21/2019, 3:30 AM
    Hi all, is there any way to save the compiled scripts to class files, and then evaluate them later by loading class files with a specific classloader? Thanks!
    n
    i
    • 3
    • 6
  • n

    Nikky

    02/22/2019, 2:09 AM
    hi, i am trying to get annoations on a function in a .kts script like so:
    fun process(@PageResult("page_2") data: String): String {
        return "one + $data"
    }
    i
    • 2
    • 4
  • n

    Nikky

    02/27/2019, 4:44 PM
    Could it be that 2 invocations of different scripts that use the same library cannot reuse instances of objects across different evaluations? so far i only tried with simple things like Strings, lists of sorts but i now tested with krangle.DataFrame and it blows up i nthe weirdest ways
    i
    • 2
    • 6
  • n

    Nikky

    03/01/2019, 10:56 AM
    i think this might solve it..
    implicitReceivers(*receivers.toTypedArray())
    but its ugly
    i
    • 2
    • 1
  • d

    Dominaezzz

    03/01/2019, 11:24 AM
    Does scripting support native?
    n
    i
    • 3
    • 3
  • d

    Dominaezzz

    03/02/2019, 1:14 PM
    Is there such a thing as a script project in IntelliJ? A project with nothing else but a KTS file and an .idea folder.
    n
    g
    • 3
    • 6
  • n

    Nikky

    03/03/2019, 5:11 PM
    this is a little concerning:

    https://i.imgur.com/MEZZIky.png▾

    i
    • 2
    • 4
  • n

    Nikky

    03/03/2019, 9:13 PM
    @ilya.chernikov who would i talk to about very specifically the available libraries and everonment of the idea kotlin plugin executing the refinment blocks ? it seems like some classes can not be loaded in them, possibly deliberately or how i can look at and enable a debug log of idea when it executes the aforementioned refinement blocks or any way to obtain type information from other script files that i could refence from a kts script my current code is in this project and branch: https://github.com/DaemonicLabs/KNote/tree/nikky/dev (execute publishTOMavenLocal and then import
    sample/
    as a gradle project (or open it in separate idea window, i never do that though, not sure how well it works)
    i
    • 2
    • 12
  • j

    josephivie

    03/08/2019, 1:51 AM
    @Ruckus It uses JSR-223, I'm pretty sure it is locked to the JVM (at least for now)
    i
    r
    +2
    • 5
    • 17
  • g

    gtnarg

    03/09/2019, 2:24 AM
    This might give you some ideas: https://pf4j.org/doc/class-loading.html and more specifically https://github.com/pf4j/pf4j/blob/master/pf4j/src/main/java/org/pf4j/PluginClassLoader.java
    n
    • 2
    • 1
  • r

    raulraja

    03/09/2019, 12:17 PM
    Is there a way to run kapt to process annotations over sources that are compiled and evaluated with JSR-223 ? We are having to provide separate helpers in Arrow docs for model classes that require kapt and annotations because we have not yet found a way to have kapt run on regular code snippets.
    i
    • 2
    • 2
  • s

    SrSouza

    03/12/2019, 1:19 PM
    Hi, I create my own Compilation Key, during the refination of the script she still existis but after the compilation my key is gonna, this is normal? I set the key in the onAnnotation
    n
    i
    • 3
    • 9
  • s

    SrSouza

    03/12/2019, 9:35 PM
    How can I load a script with a dependency from a script compiled before? The compiler don't generate a file with the bytecode right ? I just have the bytecode from the script and JvmDependency is just File
    i
    • 2
    • 2
  • n

    Nikky

    03/12/2019, 9:43 PM
    so i ended up restructuring my project to do one set of dependencies at a time and shadowJar them into a fat-jar that executes the program
    s
    • 2
    • 4
  • n

    Nikky

    03/14/2019, 8:05 PM
    is there a different grammar like http://kotlinlang.org/docs/reference/grammar.html for kts files? or.. closer to what i want.. how can i parse a file into Psi to then use for highlighting ?
    g
    i
    • 3
    • 18
  • n

    Nikky

    03/17/2019, 9:03 PM
    when using idea integration it is called 3 times for me, but it seems to cancel the first two times
    s
    i
    • 3
    • 3
  • s

    SrSouza

    03/20/2019, 7:10 PM
    Have some Compiler Configuration for the final name and package of the script? I want to change the package of her, I change the name in the FileScriptSource but is compiling with underline. Is compiling to:
    Folder_scriptname
    -.kt
    i
    • 2
    • 4
  • e

    eskatos

    03/22/2019, 10:00 AM
    or
    KotlinScriptingHost
    from
    org.jetbrains.kotlin:kotlin-scripting-jvm-host(-embeddable)
    t
    • 2
    • 1
Powered by Linen
Title
e

eskatos

03/22/2019, 10:00 AM
or
KotlinScriptingHost
from
org.jetbrains.kotlin:kotlin-scripting-jvm-host(-embeddable)
t

tapchicoma

03/22/2019, 8:10 PM
This jar only contains
kotlin.script.experimental.jvmhost.BasicJvmScriptingHost
that can't be used to run scripts
View count: 1