File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 185185---
186186
187187
188+ ### Does it also work for regular kotlin class files ` .kt ` ?
189+
190+ Yes, you can run kotlin classes through kscript. By default ` kscript ` will assume a top-level ` main ` method as entry-point.
191+
192+ However in case you're using a companion object to declare the entry point, you can indicate this via the ` //ENTRY ` directive:
193+
194+ ``` kotlin
195+ #! / usr/ bin/ env kscript
196+
197+ package test
198+
199+ // DEPS log4j:log4j:1.2.14
200+ // ENTRY Foo
201+
202+ class User (val age : Int )
203+
204+ fun findUserByName (name : String ): User = null !!
205+
206+ class Foo {
207+ companion object {
208+ @JvmStatic fun main (args : Array <String >) {
209+ println (" foo companion was called" )
210+ }
211+ }
212+ }
213+ ```
214+ The intial shebang could be left out by running the script directly with ` kscript some.kt `
215+
216+
217+
188218### How to adjust the memory settings for the JVM in my scriptlet?
189219
190220` kscript ` allows to provide a ` //KOTLIN_OPTS ` line followed by parameters passed on to ` kotlin ` similar to how dependencies are defined:
You can’t perform that action at this time.
0 commit comments