File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -253,7 +253,13 @@ fun collectRuntimeOptions(scriptText: List<String>): String {
253253 filter { it.startsWith(koptsPrefix) }.
254254 map { it.replaceFirst(koptsPrefix, " " ).trim() }
255255
256- // todo add support for @file:KotlinOpts here
256+ // support for @file:KotlinOpts see #47
257+ val annotatonPrefix = " @file:KotlinOpts("
258+ kotlinOpts + = scriptText
259+ .filter { it.startsWith(annotatonPrefix) }
260+ .map { it.replaceFirst(annotatonPrefix, " " ).split(" )" )[0 ] }
261+ .map { it.trim(' ' , ' "' ) }
262+
257263
258264 // Append $KSCRIPT_KOTLIN_OPTS if defined in the parent environment
259265 System .getenv()[" KSCRIPT_KOTLIN_OPTS" ]?.run {
Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ class Tests {
5656 collectRuntimeOptions(lines) shouldBe " -foo 3 'some file.txt' --bar"
5757 }
5858
59+ @Test
60+ fun annotOptsCollect () {
61+ val lines = listOf (
62+ " //KOTLIN_OPTS -foo 3 'some file.txt'" ,
63+ """ @file:KotlinOpts("--bar")"""
64+ )
65+
66+ collectRuntimeOptions(lines) shouldBe " -foo 3 'some file.txt' --bar"
67+ }
68+
5969
6070 @Test
6171 fun foo () {
You can’t perform that action at this time.
0 commit comments