louiscad
08/23/2021, 2:28 PMAchifal
08/26/2021, 10:41 AMkolinc -script /path/to/script
, is there a way to get the location of the script file at runtime? It's extremely needed for convenient usage of Kotlin for scripting use cases. ThanksSu5eD
09/02/2021, 9:19 AMSrSouza
09/09/2021, 6:49 PMsmallshen
09/12/2021, 5:47 PMelect
09/14/2021, 10:11 AMdependsOn
from within the scripts?elect
09/14/2021, 10:16 AMelect
09/14/2021, 8:26 PMKareem Radwan
09/15/2021, 11:53 AMignoreUnknownKeys
and coerceInputValues
?!altavir
09/15/2021, 2:15 PMSu5eD
09/18/2021, 8:07 PMAlexey Subach
09/19/2021, 11:15 PM@file:ScriptFileLocation("scriptFileLocation")
scriptFileLocation.absolutePath
The commit with the changes is available here: https://github.com/Snipx/kotlin/commit/339500282347811f269e8d67d053af5991ba813b
Would it be possible to give me some feedback around that initial approach? Or should I submit a PR and continue the discussion there?elect
09/20/2021, 11:04 AMsudo
where I have to type the pwd? Shall I directly execute the script itself with sudo
?Rob Elliot
10/11/2021, 3:44 PM.kts
file that returns an instance of that type, and by setting up their IDE to have the classpath available then they will find out when configuring it whether or not their configuration will compile, and the application can gain compilation validation of its config by evaluating the file.
But that means evaluating code that could theoretically do anything.
I’ve implemented it using JSR-223 & a SecurityManager
to try and prevent unwanted execution here: https://gist.github.com/Mahoney/8979e520b7477c9a9771fe3e1da3472a
but it feels a bit clunky, and the SecurityManager
is deprecated in Java 17 for removal in future Java releases. As I’ve just found out that Kotlin has its own scripting API, I wondered if it could be run in such a way?Su5eD
10/15/2021, 8:12 PMBasicJvmScriptingHost#eval
will result in a StackOverflowError
when scriptsInstancesSharing
is enabled.
Can't find any similar issues on YT so might as well go ahead and make oneGeorge Ciubotaru
10/21/2021, 10:13 AMScriptEngine.put()
method) and 2 internal variables: kotlin.script.engine
& kotlin.script.state
. Is there a way to get the variables declared within the script?starke
10/23/2021, 12:19 AM@file:Import
when running a script in the IDE. Getting this error when trying to add @file:Import("script1.main.kts")
to script2.main.kts
error: backend Internal error: Exception during IR lowering
File being compiled: development/script1.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50) (script2.main.kts): org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: development/script1.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
I saw this thread that suggested using useOldBackend
until the bug is fixed, but I couldn’t figure out how to set this flag when running the script in the IDE.
It also mentioned that the bug might be fixed in the kotlin 1.6 release, but I can’t find any documentation about how to specify the kotlin version for a kotlin-main-kts
script 🤔 I wanted to try Kotlin 1.6.0-RC to see if the bug disappears, but I’m not sure how to define the script’s kotlin version.
Thanks in advance!breandan
10/29/2021, 5:11 AM*.kts
file and run it, code completion, static analysis and importing did not work properly on IU-2021.3 and I didn’t bother to figure out why. Doesn't the IDE bundle it's own JDK? Scripting support should work out of the box on every project with zero configuration required.elect
11/05/2021, 12:20 AMerror: backend Internal error: Exception during code generation
File being compiled: /home/elect/IdeaProjects/incubator/scijava/scijava-function/templates/main/java/org/scijava/function/Computers.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50) (Computers.main.kts): org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during code generation
File being compiled: /home/elect/IdeaProjects/incubator/scijava/scijava-function/templates/main/java/org/scijava/function/Computers.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
dector
11/23/2021, 3:20 PM.main.kts
script in IDEA I have such issues:
• JDK is not found (import java.*
not recognized) even when I'm selecting proper JDK version manually in module settings.
• Auto-completion doesn't work for classes included with @file:DependsOn()
.
Is this expected behavior? Thanks.Sebastian Schuberth
12/21/2021, 8:45 PM.classpath
file to my project's META-INF
directory, but it seems I also need to add my project's JAR now to the compiler's classpath. How do I actually do that from the IDE? My code changes can be seen at https://github.com/oss-review-toolkit/ort/pull/4887/files#diff-b5d75d77219b5108e66671916d8001890961d0063bbff4e606b13d286374908e.adryan_ip
12/25/2021, 2:45 PMholgerbrandl
12/28/2021, 5:38 PMconst
is not supported in scripts?Piotr Krzemiński
01/12/2022, 7:20 AMholgerbrandl
01/12/2022, 8:27 PMimport javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "kotlin script, show yourself! ");
which fails
java.awt.HeadlessException
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:208)
at java.desktop/java.awt.Window.<init>(Window.java:548)
at java.desktop/java.awt.Frame.<init>(Frame.java:423)
at java.desktop/java.awt.Frame.<init>(Frame.java:388)
at java.desktop/javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1919)
at java.desktop/javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1995)
Sebastian Schuberth
01/12/2022, 9:14 PMcreateJvmCompilationConfigurationFromTemplate
lambda block, similar to like in JSR223 I can do engine.put("name", value)
?nfrankel
01/15/2022, 9:00 AMCraig
01/26/2022, 10:25 AM@KotlinScript
. Works great, using BasicJvmScriptingHost
inside a command line app. I would like a good developer experience too, so I've started an IDEA plugin, using ScriptDefinitionsProvider
which is also sort of working. Is it possible to run and debug this script in IDEA? I have no idea how to go about supplying the implicit receiver objects required by the script context. Also, is it possible to supply javadocs to the configuration? ScriptDefinitionsProvider.getDefinitionsClassPath
suggests not. Thanks.SrSouza
01/29/2022, 11:59 PMkotlin
command line to run main.kts
scripts, there is anyway to use the IntelliJ embedded Kotlin to run main.kts
scripts? I don't want to make everyone from the team install Kotlin in their machines.vpriscan
02/03/2022, 8:47 AM