Hello! I have a Kotlin Gradle project. If I create...
# scripting
v
Hello! I have a Kotlin Gradle project. If I create a
.kts
file it works anywhere except the
/src/main/kotlin
folder. The exception is
src/main/kotlin/test.kts: (3, 1): Cannot access script base class 'kotlin.script.templates.standard.ScriptTemplateWithArgs'. Check your module classpath for missing or conflicting dependencies
. What is the problem?
r
I don't understand why you would put a
.kts
file there, but I'm pretty sure that your problem is related to the fact that sources in
src/main/kotlin
are compiled in a different context; or rather that
.kts
files outside of a standard/setup location are compiled in a different context
v
@ribesg i need some classes and I need some scripts to demonstrate how to use those classes. That's why it would be most convenient to put them together. How do I manege the context the kts files are compiled in?
r
Did you try running your kotlin script from a terminal?
v
I assume directly running
kotlinc
would work because it doesn't care about gradle
r
If you don't need to run your script from a terminal, then you don't need a kotlin script
v
@ribesg well, that's not a very productive discussion, is it? I want a script for demonstration purposes
Found a solution, thanks everybody!