Nikky
02/05/2022, 3:56 PM@Serializable
classes?
how would is enable to kotlinx-serialization plugin ?
i want to write a script to do a bit of json processingjmfayard
02/14/2022, 5:25 PM@file:Import("path.kt")
is not supported by the IDE?Piotr Krzemiński
02/16/2022, 12:31 PMTobias
02/16/2022, 4:18 PMjmfayard
02/17/2022, 11:34 AMDidier Villevalois
02/23/2022, 3:20 PM.classname
file in the META-INF
of my script definition module (which, btw, is not described in the tutorial). This works well, and now I can create my script files in the same IDE project.
Now, I would need to have support for this script definition in other project. Should I create an IDEA plugin?nickheitz
02/26/2022, 11:30 AMCaused by: java.lang.ClassNotFoundException: com.intellij.openapi.util.Disposer
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
Is there an easy resolution here?nfrankel
03/03/2022, 7:01 AMZac Sweers
03/03/2022, 5:09 PM*.smain.kts
, and I was curious if that smain
naming is a convention or something else? I couldn’t find any other references explaining it in google searchesNikky
03/03/2022, 10:03 PM.main.kts
) ?
i don't want to reply on the script getting invoked always from the correct root directory or trying to guess what the correct path is..
somthing like
File(Script_main::class.java.protectionDomain.codeSource.location.toURI())
but that does not work since location in codeSource is null
does anyone know a workaround ?iguissouma
03/09/2022, 10:25 PM2022-03-09 23:20:03,637 [ 284400] ERROR - plication.impl.ApplicationImpl - Service is dying
java.lang.IllegalStateException: Service is dying
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:55)
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:54)
at org.jetbrains.kotlin.daemon.client.KotlinRemoteReplCompilerClient.<init>(KotlinRemoteReplCompilerClient.kt:51)
at org.jetbrains.kotlin.daemon.client.KotlinRemoteReplCompilerClient.<init>(KotlinRemoteReplCompilerClient.kt:27)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea$replCompiler$2.invoke(KotlinJsr223JvmScriptEngine4Idea.kt:59)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea$replCompiler$2.invoke(KotlinJsr223JvmScriptEngine4Idea.kt:27)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea.getReplCompiler(KotlinJsr223JvmScriptEngine4Idea.kt)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea$localEvaluator$2.invoke(KotlinJsr223JvmScriptEngine4Idea.kt:74)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea$localEvaluator$2.invoke(KotlinJsr223JvmScriptEngine4Idea.kt:27)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea.getLocalEvaluator(KotlinJsr223JvmScriptEngine4Idea.kt)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea.getReplEvaluator(KotlinJsr223JvmScriptEngine4Idea.kt:77)
at org.jetbrains.kotlin.jsr223.KotlinJsr223JvmScriptEngine4Idea.createState(KotlinJsr223JvmScriptEngine4Idea.kt:79)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.createState$default(KotlinJsr223JvmScriptEngineBase.kt:46)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.getCurrentState(KotlinJsr223JvmScriptEngineBase.kt:53)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.nextCodeLine(KotlinJsr223JvmScriptEngineBase.kt:44)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.compileAndEval(KotlinJsr223JvmScriptEngineBase.kt:61)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.eval(KotlinJsr223JvmScriptEngineBase.kt:31)
at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at com.chutneytesting.idea.runner.ChutneyJsonToTestEventConverter.onStartTesting$lambda-4(ChutneyJsonToTestEventConverter.kt:64)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:263)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
I’m evaluating kotlin script on an intellij idea plugin
class ChutneyKotlinJsr223JvmLocalScriptEngineFactory(val ktVirtualFile: VirtualFile, val project: Project) : KotlinJsr223JvmScriptEngineFactoryBase() {
companion object{
private val LOG = Logger.getInstance(ChutneyKotlinJsr223JvmLocalScriptEngineFactory::class.java)
}
override fun getScriptEngine(): ScriptEngine {
val module = ModuleUtil.findModuleForFile(ktVirtualFile, project)
?: error("cannot find module")
val classes = ModuleRootManager.getInstance(module).orderEntries().classes()
val roots = classes
.roots.filterIsInstance<FsRoot>()
.map { it.path.substringBeforeLast('!') }
.map { File(it) }
.filter { it.exists() }
val target = classes
.roots.filter { it.isDirectory }
.filter { it.path.lowercase().endsWith("classes") }
.map { File(it.path) }
.filter { it.exists() }
<http://LOG.info|LOG.info>("dependencies for ${module.name}" + roots + classes)
return KotlinJsr223JvmScriptEngine4Idea(
this,
scriptCompilationClasspathFromContextOrStlib(wholeClasspath = true) + KotlinJars.kotlinScriptStandardJars + roots + target,
"kotlin.script.templates.standard.ScriptTemplateWithBindings",
{ ctx, argTypes ->
ScriptArgsWithTypes(
arrayOf(ctx.getBindings(ScriptContext.ENGINE_SCOPE)),
argTypes ?: emptyArray()
)
},
arrayOf(Map::class)
)
}
}
ribesg
03/15/2022, 10:28 AMNikky
03/20/2022, 10:53 AM.main.kts
can i use @file:Repositry
to point to a local folder repository ?
@file:Repository("/home/nikky/dev/forks/github-actions-kotlin-dsl/localRepo/")
does not seem to work
or do repostories for this need to be http based ?Nikky
03/23/2022, 2:16 PM.main.kts
files using kotlinc from the kotlin gradle plugin ?Slackbot
03/24/2022, 3:51 PMAdam S
04/17/2022, 9:01 PMjava.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl.<init>(org.jetbrains.kotlin.com.intellij.psi.PsiManager)'
I'm not sure what the problem could be, or how to try and find out. Any ideas?Matthieu Stombellini
04/24/2022, 3:44 PM@file:Import("somefile.main.kts")
annotation to a .main.kts script, the autocompletion and syntax highlighting on that file completely disappears (beyond very simple things like coloring keywords) after an "Apply context". Is this a known issue?Matthieu Stombellini
05/16/2022, 9:37 PM.custom.kts
files. I would like to retrieve, at runtime, a list of all of the classes that were compiled from said .custom.kts
files, e.g. with their FQN in a file somewhere within META-INF (similar to (I believe?) service providers in Java). Is there a way to do this with just the script compilation configs that are offered? I'd like to do this without compiler plugins or KSP in order to keep my build process simple. Is there a way to do this?
(There are multiple use cases on my end, such as doing some sort of "feature discovery" at runtime by looking at all the classes that got generated from a .feature.kts
file of some sort)SrSouza
06/03/2022, 12:31 AMsuspend
I want to know if this two things are in the Roadmap as well and what is there is anyplan to resolve the first one.Vampire
06/16/2022, 9:43 PM*.main.kts
script run?
Especially without having Kotlin installed on the local machine.
Or is it really required to have Kotlin installed and then invoke it with the script as argument?Su5eD
06/17/2022, 6:27 PMstarke
06/23/2022, 10:25 PMfoo.main.kts
when I use @file:Import
, but can’t figure out a way to access classes that are defined in foo.main.kts
@file:Import("foo.main.kts")
I tried referencing the class like Foo_main.MyClass()
, but it doesn’t seem to work 🤔
Thanks in advance!starke
06/24/2022, 7:56 PMmain.kts
script?
E.g. If I have script1.main.kts
and want to execute script2.main.kts
from inside that script. Hopefully in a way that I can pass arguments too.
🙏Piotr Krzemiński
06/26/2022, 9:05 AMVampire
06/26/2022, 8:57 PM.main.kts
script.
I guess it uses whatever Kotlin version you are running it with.
But how to make sure it is at least version X?
Do you have to manually check that if necessary?
Actually more important, how does IntelliJ know which stdlib to use for navigation and completion?
I have a script that I intend to run only with Kotlin 1.7.0, so I could use Kotlin 1.7.0 API.
But even if I add a @file:DependsOn
on 1.7.0 stdlib-jdk8, it still navigates to 1.3.72 Kotlin stdlib.
The installed plugin is 1.7.0 and the complier settings have "latest stable (1.7)" for language and api version.zt
06/29/2022, 4:03 AMribesg
06/29/2022, 9:50 AMandylamax
07/04/2022, 1:41 PM./ls -al
) from a kscript?
without going through the whole file api?Zac Sweers
07/07/2022, 4:07 PMelect
07/12/2022, 8:30 PMplugins
block which gets evaluated and based on its content, specific code would be generated and made available to the rest of the script.
In Gradle you have to hit refresh in the Gradle window, in order to trigger this mechanism, but what about in a classic script instead?