It'd be great if kscript could match behavior to be 100% compatible with the 'Kotlin scripting support' annotations. Even if one writes a script aiming for the standard compiler command, I could run it with kscript and benefit from caching and its other features.
vararg support
Adding multiple repositories with a single annotation (source):
@file:Repository("https://jitpack.io", "https://repo.maven.apache.org/maven2")
@file:DependsOn("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.11.0", "org.jetbrains.kotlinx:dataframe:0.9.1")
but kscript doesn't support vararg in Repository, parsing the second arg as a repository username:
[kscript] Adding repository: Repository(id=, url=https://jitpack.io, user=https://repo.maven.apache.org/maven2, password=)
Line break support
Breaking line inside annotations is supported by kotlinc, but isn't supported by kscript:
Line break in DependsOn
@file:Repository("https://repo.maven.apache.org/maven2")
@file:DependsOn(
"com.squareup.okio:okio:3.3.0",
"org.jetbrains.kotlinx:dataframe:0.9.1",
)
[kscript] Adding repository: Repository(id=, url=https://repo.maven.apache.org/maven2, user=, password=)
[kscript] [ERROR] Compilation of scriplet failed:
[kscript] [ERROR] Command : 'bash -c /opt/homebrew/Cellar/kotlin/1.8.0/libexec/bin/kotlinc -d '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/scriplet.jar' '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Dataframe_test_main.kts' '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Main_Dataframe_test_main.kt''
[kscript] [ERROR] Exit Code : 1
[kscript] [ERROR] Stdout : ''
[kscript] [ERROR] Stderr : '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Dataframe_test_main.kts:6:2: error: expecting an expression[nl])[nl] ^[nl]/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Dataframe_test_main.kts:3:7: error: unresolved reference: DependsOn[nl]@file:DependsOn([nl] ^[nl]'
[kscript] [ERROR]
Line break in Repository
@file:Repository(
"https://jitpack.io",
"https://repo.maven.apache.org/maven2",
)
@file:DependsOn("com.squareup.okio:okio:3.3.0", "org.jetbrains.kotlinx:dataframe:0.9.1")
[kscript] Adding repository: Repository(id=, url=, user=, password=)
Note: using multiple Repository and DependsOn annotations has the same behavior in both kotlinc and kscript, a good workaround to make scripts compatible with both
@file:Repository("https://jitpack.io")
@file:Repository("https://repo.maven.apache.org/maven2")
@file:DependsOn("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.11.0")
@file:DependsOn("org.jetbrains.kotlinx:dataframe:0.9.1")