File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
src/main/kotlin/kscript/app Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -204,12 +204,15 @@ fun main(args: Array<String>) {
204204
205205 val wrapperSrcArg = if (scriptFileExt == " kts" ) {
206206 val mainKotlin = File (createTempDir(" kscript" ), execClassName + " .kt" )
207+
208+ val classReference = (script.pckg ? : " " ) + className
209+
207210 mainKotlin.writeText("""
208211 class Main_${className} {
209212 companion object {
210213 @JvmStatic
211214 fun main(args: Array<String>) {
212- val script = Main_${className} ::class.java.classLoader.loadClass("${className } ")
215+ val script = Main_${className} ::class.java.classLoader.loadClass("${classReference } ")
213216 script.getDeclaredConstructor(Array<String>::class.java).newInstance(args);
214217 }
215218 }
@@ -235,7 +238,6 @@ fun main(args: Array<String>) {
235238}
236239
237240
238-
239241/* * Determine the latest version by checking github repo and print info if newer version is available. */
240242private fun versionCheck () {
241243
Original file line number Diff line number Diff line change 1+ #! / usr/ bin/ env kscript
2+
3+ @file:KotlinOpts(" -J-Xmx5g" )
4+
5+ package foo
6+
7+ import KotlinOpts
8+
9+ // import kscript.annotations.*
10+
11+
12+ println (" I live in a package!" )
Original file line number Diff line number Diff line change @@ -187,10 +187,17 @@ assert "kscript ${KSCRIPT_HOME}/test/resources/kt_tests/default_entry_nopckg.kt"
187187
188188assert " kscript ${KSCRIPT_HOME} /test/resources/kt_tests/default_entry_withpckg.kt" " main was called"
189189
190+
191+ # # also make sure that kts in package can be run via kscript
192+ assert " ${KSCRIPT_HOME} /test/resources/script_in_pckg.kts" " I live in a package!"
193+
194+
190195assert_end kt_support
191196
192197
193198
199+
200+
194201# #######################################################################################################################
195202# # custom interpreters
196203
You can’t perform that action at this time.
0 commit comments