How would I go about running a simple kotlin scrip...
# announcements
a
How would I go about running a simple kotlin script? I want to try out a library and I don't feel like creating a separate project for it, I've found that you could just add
@file:DependsOn("...")
annotation on it and it should work, I'm getting an error that "DependsOn" doesn't exist
google 1
b
Your script needs to be run with kotlinc -script script.kts
a
I've tried that, I'm still getting "error: unresolved Reference: DependsOn"
b
Then make sure your script is named as *.main.kts and check that your kotlinc version is at least 1.4
a
even though the docs on github do suggest that's the way you should do it. I didn't find anything else on there: https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md
kotlinc is 1.4.10, lemme rename the file
huh, renaming the file worked. The docs don't explicitly mention that the file should be *.main.kts, even though all the examples do have it.
Thanks!
b
They did in 1.4 release notes. Probably wasn't updated in the keep
n
a
is the @file:param() supported though?
n
i didn’t try that
so i don’t know
a
thanks, i'll make sure to read your post! 🙂 The param is the leas of my issues. But it doesn't seem to work right now.
I've tried the way the suggest in the KEEP file, maybe I'm missing something
n
i had to go through a lot of back and forth it’s not as straightforward as i thought so copying-pasting my code is a good starting point 😉
a
i got it running more or less, but now I'm struggling with the lib I'm using 😄 I'm very new to Java/Kotlin and just trying to go by looking at the tests since there are no docs. Yay. 😄
n
if you’re not familiar with kotlin using scripting adds an additional issue perhaps keeping with a traditional maven build would be easier? at least you would find plenty more of documentation are you using intellij?
a
yup, i'm using intellij. I mean, I got passed the scripting part. It's working. 🙂
👍 1