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

    Paul Woitaschek

    10/30/2018, 9:31 AM
    I can't find information on this, I found different things on different places: Is there an official way to define Maven dependencies and to cashe compilation or is ktscript still the preferred way for running scripts? I found it super convenient to just append --idea and have an idea instance set up.
    i
    • 2
    • 1
  • j

    jasoet

    10/31/2018, 10:54 AM
    I want to use kotlin scripting as my devops related script and run it on Docker Container. Can we download the deps first so when executing
    kts
    it will not fetch jar file from maven repo?
    v
    a
    d
    • 4
    • 3
  • p

    Paul Woitaschek

    11/01/2018, 3:46 PM
    @holgerbrandl I noticed that kscript only works if you put everything in DependsOn on a single line. Is that expected?
    h
    • 2
    • 1
  • p

    Paul Woitaschek

    11/01/2018, 3:51 PM
    https://github.com/holgerbrandl/kscript/issues/191
    h
    • 2
    • 2
  • l

    louiscad

    11/30/2018, 4:59 PM
    What do you mean exactly? I have this file at the root of an Android Studio project (which uses Kotlin and
    .gradle.kts
    ), but the syntax highlighting is not there apart from keywords and strings as I said.
    g
    a
    i
    • 4
    • 8
  • r

    ribesg

    12/03/2018, 10:50 AM
    How would I create a simple kotlin script and edit it using IntelliJ? Do I really need to create a project?
    g
    o
    • 3
    • 5
  • b

    bod

    12/06/2018, 2:18 PM
    Hello, World! I was looking at kts for the first time. It’s not clear whether it’s possible to write scripts that depend on some maven lib. I’ve seen the
    @file:dependsOn
    annotation in the KEEP, but is it implemented?
    g
    • 2
    • 3
  • n

    Nikky

    12/14/2018, 2:09 AM
    well limited sounds better than not possible at all @ilya.chernikov is there a issue for that i can track ?
    i
    • 2
    • 1
  • n

    Nikky

    12/22/2018, 8:17 PM
    everything works fince except where i try to use infix functions or lambdas
    a
    • 2
    • 4
  • a

    amanda.hinchman-dominguez

    01/05/2019, 6:15 PM
    Are options 1 and 2 completely off-base?
    n
    • 2
    • 30
  • s

    serebit

    01/05/2019, 7:54 PM
    I'm trying to convert my JSR-223 usages into the new experimental scripting API, but every script I attempt to compile gives me two errors: - One instance of
    No class roots are found in the JDK path: /usr/lib64/openjdk-8/jre
    - Several instances of
    Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
    How can I address these?
    c
    n
    • 3
    • 28
  • a

    amanda.hinchman-dominguez

    01/05/2019, 9:11 PM
    compilerOptions.append("-jvm-target", "1.8")
    n
    • 2
    • 6
  • c

    Czar

    01/06/2019, 12:23 AM
    HA! After couple of hours of digging through kotlin code I've found the problem, will try to contribute fix next week 🙂
    💯 2
    ➕ 2
    i
    n
    • 3
    • 12
  • i

    Icaro Temponi

    01/18/2019, 4:32 PM
    How can I turn on the syntax highlighting for top level kts scripts on Intellij? tried adding the stdlib to the module but didn't work
    n
    i
    • 3
    • 21
  • n

    Nikky

    01/19/2019, 4:29 AM
    apparently a kotlin script cannot implement abstract function the script definition.. or at least ide things its a conflicting overload
    i
    • 2
    • 6
  • n

    Nikky

    01/21/2019, 10:33 AM
    but despite the loads of complaints/wishes for improvement i have for scripting it is still better than any alternative, good job JB
    ❤️ 1
    ➕ 1
    i
    • 2
    • 1
  • n

    Nikky

    01/22/2019, 3:15 AM
    @egorand you mentioned having 0 experience with kotlin scripting and want to check it out, please check out my repo here: https://github.com/NikkyAI/MinimalScriptingExample
    🙏 2
    y
    e
    • 3
    • 8
  • n

    Nikky

    01/22/2019, 12:34 PM
    one thing that came to mind earlier.. is it possible to cache the script compilation results ?
    :yes: 1
    i
    • 2
    • 2
  • s

    SrSouza

    01/22/2019, 6:49 PM
    Hi guys, i'm trying to make my script be recognized by the intellij, I create the file on templates but still not working, someone can help me ?
    n
    b
    i
    • 4
    • 28
  • s

    SrSouza

    01/23/2019, 4:45 PM
    Hi @ilya.chernikov, how I can tell the JvmScriptCompier the ClassLoader to load the script? all JvmGetScriptingClass properties is private
    i
    • 2
    • 6
  • s

    SrSouza

    01/24/2019, 5:19 PM
    @ilya.chernikov Hi, when a should use
    ScriptEvaluationConfigurationKeys.constructorArgs
    ? My code loads the script and return to me a KClass, no a new object from the compiled script
    val evalConfig = ScriptEvaluationConfiguration {
            constructorArgs(plugin)
            set(JvmScriptEvaluationConfiguration.actualClassLoader, bukkriptClassLoader)
        }
    
        val clazz = bukkriptCompiledScript.compiledScript.getClass(evalConfig).resultOrSeveral(plugin)
    In this case a should not use
    constructorArgs()
    ?
    i
    • 2
    • 2
  • s

    SrSouza

    01/24/2019, 7:59 PM
    @ilya.chernikov you have plan to in the feature create a Parse object that you use on the compilation. In my project a need to parse two times, the first ALWAYS will Fail because he is used for get something from a annotation and put on a list to sort the scripts for compile correctly. You can see here: https://github.com/DevSrSouza/Bukkript/blob/recode/host/src/main/kotlin/br/com/devsrsouza/bukkript/host/Host.kt#L26 If the script API has a parse object or something, this could be faster
    i
    • 2
    • 3
  • s

    serebit

    01/24/2019, 8:40 PM
    The files have highlighting and completion, but the default imports aren't being recognized by IntelliJ and are marked as red.
    i
    • 2
    • 9
  • n

    Nikky

    01/27/2019, 7:16 PM
    does anyone know of a way to make gradle spit out the location of the jdk that is being used ? that would be very helpful for passing it as system property to the scripting stuff
    c
    s
    • 3
    • 8
  • s

    SrSouza

    01/28/2019, 7:39 PM
    Hi @ilya.chernikov, I'am with a problem in refine annotations. My script have a annotation that all the parameters have default values, and in the script I put one parameter and get this exception. I guess that the parse not work with annotations with default parameters. My annotation class:
    @Target(AnnotationTarget.FILE)
    @Retention(AnnotationRetention.SOURCE)
    @Repeatable
    annotation class Script(
        val name: String = "",
        val version: String = "",
        val author: String = "",
        val authors: Array<String> = emptyArray(),
        val website: String = "",
        val depend: Array<String> = emptyArray(),
        val pluginDepend: Array<String> = emptyArray()
    )
    -.kt
    i
    • 2
    • 5
  • l

    Lorin

    01/29/2019, 8:28 AM
    Hi all, I encounter some issues when I’m trying to integrate kotlin-scripting (v1.3.11) into my Apache Flink (v1.7.1) application. One of the runtime dependencies of kotlin-scripting is kotlin-compiler-1.3.11.jar, which conflicts with Flink due to log4j.
    Exception in thread "main" java.lang.NoSuchMethodError: org.apache.log4j.Level.toLevel(Ljava/lang/String;Lorg/apache/log4j/Level;)Lorg/apache/log4j/Level;
    	at org.apache.log4j.helpers.OptionConverter.toLevel(OptionConverter.java:198)
    	at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:753)
    	at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
    	at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
    	at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
    	at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
    	at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
    	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:81)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:329)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:349)
    	at org.apache.flink.client.cli.CliFrontend.<clinit>(CliFrontend.java:99)
    So I use kotlin-compiler-embeddable-1.3.11.jar as the runtime dependency instead. The exception above is gone, but the following error occurs when evaluating kotlin script:
    Failure(reports=[ScriptDiagnostic(message=com/intellij/openapi/util/Disposer, severity=ERROR, location=null, exception=java.lang.NoClassDefFoundError: com/intellij/openapi/util/Disposer)])
    Does anyone have idea how to solve this issue? Is it possible to make kotlin-compiler-embeddable-1.3.11.jar as the default runtime dependency of kotlin-scripting? Thanks!
    n
    i
    • 3
    • 32
  • n

    Nikky

    01/29/2019, 11:42 AM
    i did the same.. replcing it with -embedable.. saves me a gradn total of 2 MB on the jar it seems
    i
    • 2
    • 2
  • a

    altavir

    02/01/2019, 6:29 PM
    I figured out that I need to add
    implicitReceivers
    both in compilation configuration and evaluation configuration, but now I have
    java.lang.IllegalArgumentException: Unknown key Key(baseClass)
    -.kt
    n
    i
    • 3
    • 16
  • n

    Nikky

    02/03/2019, 10:13 AM
    i am guessing that custom annotations giving access to new symbols will also probably not be supported by IDEA ?
    e
    • 2
    • 1
  • e

    efemoney

    02/04/2019, 3:09 AM
    Personally, I was trying to generate kts files in that step (with kotlinpoet) and add them as
    importScripts
    . Doesnt seem to run my code tho 😞
    n
    • 2
    • 5
Powered by Linen
Title
e

efemoney

02/04/2019, 3:09 AM
Personally, I was trying to generate kts files in that step (with kotlinpoet) and add them as
importScripts
. Doesnt seem to run my code tho 😞
n

Nikky

02/04/2019, 5:47 AM
that actually works.. it tested it.. just not the IDE integration part
i solved it by added all files into sourceroots via gradle
downside is that all things get compiled multiple times now.. once by gradle and once by kotlin scripting
e

efemoney

02/04/2019, 10:42 AM
Yep. IDE integration also works too if they are in source root.
n

Nikky

02/04/2019, 11:19 AM
the problem with that is that runnig a gradle task like a JavaExec will waste effort and might not accurately reflect which symbols are actually available when you just run the jar
View count: 8