Running a kotlin worksheet, its working directory ...
# intellij
k
Running a kotlin worksheet, its working directory seems to be the working directory of intellij. How can the worksheet get the project directory (or the directory of its own source file, maybe?) so I'm able to work with the project's files?
p
With Scratch files you can select the module to include in the classpath. But these live outside of the project, so not the same as worksheets
If you define the WS on the
src/kotlin
folder and you add this dependency:
Copy code
implementation(kotlin("script-runtime"))
It seems to be able to pick up the module classpath
🤔 1
Probably worth adding a separate configuration on gradle that depends on the main one so we don’t add unneeded dependencies on production
a
I think currently you will have to hardcode the project path inside the worksheet. Please vote/watch this feature request for updates: https://youtrack.jetbrains.com/issue/KT-38448
🔖 1