I'm trying to use a custom definition for kts file...
# scripting
m
I'm trying to use a custom definition for kts files, but I can't seem to get intellij to pick up on the project's script definitions for declared variables. Is there a guide for this?
v
Hi, things have shifted a lot, so I guess there is no up-to-date step-by-step documentation on custom scripting but I can try to help you in this thread; What do you have now and what are you trying to achieve?
also I've listed the issue on that https://youtrack.jetbrains.com/issue/KTIJ-38917 upvote if you think we need it
m
Right now I've got:
Copy code
@KotlinScript(
    displayName = "Game Script",
    fileExtension = "script.kts",
    compilationConfiguration = GameScriptDefinition::class
)
abstract class GameScript

object GameScriptDefinition : ScriptCompilationConfiguration({
    defaultImports()

    providedProperties(
        "game" to GameManager::class,
    )
}) {
    private fun readResolve(): Any = GameScriptDefinition
}
as well as a
com.intercept.script.GameScript
file in the same meta-inf directory, but
game
is unresolved in IJ.
I've already tried to invalidate caches, import it as subproject, but neither seemed to work
v
what IDEA version are you using atm?
m
IntelliJ IDEA 2026.1 Build #IU-261.22158.277, built on March 25, 2026 Source revision: 89c647576f1d2
v
can you show me Kotlin Scripting settings?
m
Where can I find those?
v
In regular 'Settings' window
m
I tried adding
com.intercept.script.GameScript
in the
script definition classes to load
section but search didnt find anything
v
have you built you project? for example with gradle jar task?
m
Yes, I've ran main.kt several times
v
I'm not sure it's similar, I need exact .jar file with the script definition to be in /build/ folder or /out folder
can you check or show me if it's there?
m
It's not, though it's weird that that's required.
v
it's kinda weird. but otherwise how can you provide the parity with running from cli? we need to provide definition classpath to kotlinc when we execute from terminal
but the tooling can be better from our side, that's for sure
did it work?
but the tooling can be better from our side, that's for sure
but it's hard to do so without a proper amount of use-cases
m
It found the definition, but it's still marking the variable as an unresolved reference in IDE
At this point it would probably be easier to write a FIR plugin to resolve the type of the variable and enable project plugins in IJ
Looks like it was caused by the Junie plugin, disabling it and reloading configuration seemed to work. It does reset the custom scripts every time I close the project though
v
we can check your use-case in the following EAP