Daniel Pitts
11/07/2023, 3:33 PMScriptCompilationConfiguration
and ScriptEvaluationConfiguration
?Daniel Pitts
11/07/2023, 3:45 PMscriptExecutionWrapper
?elect
11/10/2023, 4:45 PMDaniel Pitts
11/10/2023, 10:24 PMPiotr Krzemiński
11/11/2023, 9:15 AM#!/usr/bin/env kotlin
println("Hello from Kotlin!")
(see here) took 13 seconds. I tried running the script through kotlinc
instead of the shebang, and passing -verbose
, but I didn't notice anything interesting. Could you hint me how I can learn what takes so much time? Is it compilation, or something else? I'm also going to create a ticket on the Kotlin side, IMO worth addressing for the sake of making Kotlin scripting a viable alternative to e.g. Python.elect
11/13/2023, 9:51 AMkts
file in his Idea and fill out the fields of a class (or whatever) and nothing more
is this something possible?Piotr Krzemiński
11/14/2023, 7:31 AMribesg
11/24/2023, 10:58 AMjava.lang.NoSuchMethodError: 'void org.slf4j.Logger.info(java.lang.String, java.lang.Throwable)'
They all rely on API clients that use SLF4J for logging. Anyone knows why SLF4J would no longer work in scripts? I changed dependencies versions (Kotlin, Ktor, etc.) but my code didn't change
If I put my script code in a normal Gradle Kotlin project with the same dependencies it runs fine.
This script fails on the second logger call:
#!/usr/bin/env kotlin
@file:Repository(
"<https://my-repository>",
options = ["username=my-repository", "password=my-repository"],
)
@file:DependsOn("my:log-jvm:42")
import my.log.Log
import org.slf4j.LoggerFactory
LoggerFactory.getLogger("Tmp").info("Hello World!")
Log("Tmp").info("Hello World!")
[main] INFO Tmp - Hello World!
java.lang.NoSuchMethodError: 'void org.slf4j.Logger.info(java.lang.String, java.lang.Throwable)'
But this code runs fine in a single kotlin JVM Gradle project with one dependency (the exact same one):
import my.log.Log
import org.slf4j.LoggerFactory
fun main() {
LoggerFactory.getLogger("Tmp").info("Hello World!")
Log("Tmp").info("Hello World!")
}
[main] INFO Tmp - Hello World!
[main] INFO Tmp - Hello World!
Daniel Pitts
11/26/2023, 9:20 PMDaniel Pitts
11/28/2023, 3:59 PMDaniel Pitts
12/03/2023, 9:59 PMwarning: default scripting plugin is disabled: The provided plugin org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar is not compatible with this version of compiler
error: unable to evaluate script, no scripting plugin loaded
Daniel Pitts
12/05/2023, 5:02 AMMockProject
has been moved to a different package, but the intellij kotlin plugin is not from the shaded jar, and it's using the original package.Sebastian Schuberth
12/07/2023, 3:45 PMSebastian Schuberth
12/15/2023, 9:30 AM.main.kts
script, args[0]
does not refer to the script itself (like known prom other programming languages), but to first script argument (meaning you'll get an ArrayIndexOutOfBoundsException
if you try to access it while passing no arguments to the script). So, it there another way to get the script's location from the script itself, in order to construct paths relative to it?István Mészáros
12/15/2023, 11:18 AMclass MyScriptConfig : ScriptCompilationConfiguration({
...
compilerOptions(
"-Xcontent-receivers"
)
})
But IDEA still does not recognize the context (...)
syntax.Piotr Krzemiński
12/16/2023, 5:36 PMzt
01/04/2024, 6:05 AM#!/usr/bin/env -S kotlinc -Xplugin=./compiler-hosted-1.5.7.1.jar -language-version=2.0 -jvm-target=17 -script --
@file:Repository("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
@file:DependsOn("org.jetbrains.compose.runtime:runtime-desktop:1.5.11")
And all I get is this meaningless error, adding -verbose gives me information but none of it is of use
warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features
error: java.lang.StackOverflowError (test.main.kts): java.lang.StackOverflowError
Adding the dependency on runtime-desktop causes that error, compose compiler requires that dependency however.
Also this is kotlin 1.9.22Eugen Martynov
01/09/2024, 5:22 PMStan van der Bend
01/12/2024, 10:01 AMhuman ardaki
01/20/2024, 9:53 PMDaniel Karnaukh
01/26/2024, 5:09 PMPixelHamster
01/27/2024, 11:42 PMEugen Martynov
02/02/2024, 9:58 AMEugen Martynov
02/02/2024, 9:59 AMEugen Martynov
02/05/2024, 11:02 AMJason
02/07/2024, 7:11 PMJason
02/07/2024, 8:39 PMVladislav Ermolin
02/09/2024, 5:42 PMmain.kts
host.
I’m Android developer, so my main IDE is Android Studio. I want my scripts appear as another entry in the project tree, when “android” view is enabled.
I started with creating a new gradle module and including it into project, through the settings.gradle.kts
. I converted a couple of scripts to the .main.kts
ones, fixed imports and annotations. I put them in the root folder of the newly created module. Worth mentioning, that I converted 4 script files, 3 of which are just utilities, while the 4th one imports and uses them.
I’m able to execute the 4th script file from the IDE and it works fine. However, the code navigation and highlightins are completely broken.
In particular I see the following problems:
• On top of each file there’s a warning saying Multiple script definitions are applicable to this script. MainKtsScript is used.
• In the “Problems” section of every file, which imports another file, there’s a problem saying Imported script file {path_to_another_file} is not loaded. Check your script imports
I’m particularly interested in the latter. Is there any way to “re-load” scripts?
Any other suggestions on what I’m doing wrong are welcomed 🙂Primoz Delopst
02/22/2024, 2:46 PMjvm {
dependenciesFromClassContext(
Script::class,
"hapi-fhir-base",
"hapi-fhir-structures-r5",
"hapi-fhir-structures-r4",
"hapi-fhir-structures-dstu3",
"hapi-fhir-structures-dstu2",
"org.hl7.fhir.dstu2016may",
"org.hl7.fhir.r5",
"org.hl7.fhir.r4",
"org.hl7.fhir.dstu2",
"org.hl7.fhir.dstu3",
"hapi-fhir-converter",
wholeClasspath = false,
)
}
In the background I am also using hapi-fhir-client in sime helper functions. I intentionally did not add hapi-fhir-client to the libraries since I do not want user to use REST client in the scripts directly. Since I am dependant to the hapi-fhir-client (the dependency is on the project classpath) I am still able to import and use classes from hapi-fhir-client dependency in IDE when writing the script even if the library is not available to the script - of course script evaluation than fails. Is there an option to prevent importing and using classes from hapi-fhir-client dependency? Any help is appreciated. Thanks in advance.Dmytro Serdiuk
02/29/2024, 12:19 PM