Do scripts accept arguments/parameters? Is there a way to pass objects to them?


Hi All!

I’m working on the kotlin vertx wrapper and I’m having a bit of a time here.  Alex T’s script showed values being passed to the script (Vertx object, Verticle object, etc).  Of course this seems to violate normal kotlin syntax and certainly confused IDEA.  He then created an instance of the script with:

clazz.getConstructors()!![0]!!.newInstance(vertx, container, this)

Is there any capabilities for Kotlin to do something like this?  There is not a whole lot of documentation on scripts and I’m sort of assuming they’re regular old kotlin files with a main function.  But it would be fantastic for kotlin to be able to have launching scripts for vertx.  




I bumping in general but I think this is a straight forward question.  Anyone able to help?


Yes, scripts can take parameters. You can find some examples here:


Hey Andrey!

I was thrown off by Idea showing a red error.  Is there any way to communicate with idea that these parameters are passed in at execution time or is that just something that has to be fixed by the IDE team?



Hi Steve,

You are right, the IDE does not support scripts for now.


Well that was 5 years ago… IDE still not supporting scripts?


There is support for scripts in the IDEA but it currently missing crucial component - ability to call project code. You can follow this discussion. Also there is a link there to tracker. You can vote it up if you want this feature.

Personally, I am waiting for it with great anticipation. For now I use groovy scripts, but Kotlin, being type safe is much better.