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?Vampire
06/16/2022, 11:48 PMplugins {
kotlin("jvm") version "1.7.0"
}
repositories {
mavenCentral()
}
kotlin {
sourceSets {
main {
kotlin.srcDir("path/to/kts/file")
}
}
}
dependencies {
implementation(kotlin("main-kts"))
}
but that results in
failed to access class org.jetbrains.kotlin.com.google.common.base.Platform from class org.jetbrains.kotlin.com.google.common.base.Ticker$1 (org.jetbrains.kotlin.com.google.common.base.Platform is in unnamed module of loader 'app'; org.jetbrains.kotlin.com.google.common.base.Ticker$1 is in unnamed module of loader java.net.URLClassLoader @11cfd2b3)
😞Tobias
06/17/2022, 11:18 AMVampire
06/17/2022, 12:58 PMbuildSrc
?
Or you mean you made the Script a Gradle plugin?
That would unfortunately not be feasible in my case.
I want to start using the github-actions-kotlin-dsl
and I'd like to have a Gradle task that can execute it,
so it must be that exact *.main.kts
file that is executed.Tobias
06/17/2022, 12:59 PMTobias
06/17/2022, 1:01 PMilya.chernikov
06/17/2022, 2:07 PMkotlin-compiler-embeddable
kotlin-scripting-compiler-embeddable
kotlin-main-kts
kotlin-script-runtime
most likely kotlin-stdlib
and all transitive dependencies.
then you'll need to run
java -cp <classpath from deps above> org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -script <your script>.main.kts
.Vampire
06/17/2022, 2:09 PMas a part of the build processIf you mean in-process, no. I just want to be able to execute a Gradle task that runs the
*.main.kts
script without the need to have Kotlin available in the path of the system.ilya.chernikov
06/17/2022, 2:22 PMVampire
06/17/2022, 2:36 PMilya.chernikov
06/17/2022, 2:43 PMribesg
06/17/2022, 2:47 PMilya.chernikov
06/17/2022, 2:48 PMVampire
06/17/2022, 2:48 PMribesg
06/17/2022, 2:48 PMVampire
06/17/2022, 2:49 PMVampire
06/17/2022, 2:49 PMbash cli is understandably much more common than kotlin cliOn Linux
ribesg
06/17/2022, 2:49 PMVampire
06/17/2022, 2:50 PMPaul Woitaschek
06/17/2022, 3:25 PMPaul Woitaschek
06/17/2022, 3:26 PMVampire
06/17/2022, 3:27 PM*.main.kts
script without using kts
?
As I already explained,
I want to start using the github-actions-kotlin-dsl
and I'd like to have a Gradle task that can execute it,
so it must be that exact *.main.kts
file that is executed.Paul Woitaschek
06/17/2022, 3:28 PMVampire
06/17/2022, 3:28 PMPaul Woitaschek
06/17/2022, 3:31 PMVampire
06/17/2022, 3:33 PMPATH
Vampire
06/17/2022, 3:33 PMPaul Woitaschek
06/17/2022, 3:34 PMVampire
06/17/2022, 3:36 PMPaul Woitaschek
06/17/2022, 3:41 PMPaul Woitaschek
06/17/2022, 3:41 PMPaul Woitaschek
06/17/2022, 3:42 PMVampire
06/17/2022, 3:45 PMPATH
.Paul Woitaschek
06/17/2022, 3:49 PMVampire
06/17/2022, 3:50 PMVampire
06/17/2022, 3:50 PMPaul Woitaschek
06/17/2022, 3:51 PMVampire
06/17/2022, 4:10 PMPaul Woitaschek
06/17/2022, 4:42 PMmbonnin
06/17/2022, 4:44 PMmain()
to maven central and your main.kts becomes just 2 lines 😅mbonnin
06/17/2022, 4:45 PMmain()
from Gradle)Paul Woitaschek
06/17/2022, 4:46 PMmbonnin
06/17/2022, 4:48 PMmbonnin
06/17/2022, 4:48 PMVampire
06/17/2022, 10:05 PMSo: You move the logic out of the kts file into a real gradle module. Then you can’t need the kts file at all and can run it without kotlin installed.So you mean faking it were a
*.main.kts
file by naming it like that, fooling the tool calling it
and with the shebang make it a Bash script instead?
That sounds pretty ugly but would actually work in my specific case I think.
I really don’t see the need why it needs to be a kts file.Because that is what
github-actions-kotlin-dsl
dictates and what actually is all the sense of it.
To have a Kotlin DSL to define a GitHub actions workflow.
Or you publish a jar with a simpleto maven central and your main.kts becomes just 2 lines 😅main()
(and you callWhile also pretty ugly probably, that would indeed work maybe. Of course not published to MC, but published to a local repo that is then used. But that seems also pretty from behind through the back into the eye as we say in German. I think a task that just can invoke the thefrom Gradle)main()
*.main.kts
should still be the way to go.Paul Woitaschek
06/18/2022, 5:29 AMVampire
06/18/2022, 10:13 AMPaul Woitaschek
06/18/2022, 10:24 AMVampire
06/18/2022, 10:27 AMPaul Woitaschek
06/18/2022, 10:28 AMVampire
06/18/2022, 10:29 AMVampire
06/18/2022, 10:29 AMPaul Woitaschek
06/18/2022, 10:30 AMVampire
06/18/2022, 10:32 AMVampire
06/19/2022, 2:39 AMval bar by configurations.creating
dependencies {
bar(kotlin("compiler-embeddable", "1.7.0"))
bar(kotlin("scripting-compiler-embeddable", "1.7.0"))
bar(kotlin("main-kts", "1.7.0"))
bar(kotlin("script-runtime", "1.7.0"))
bar(kotlin("stdlib", "1.7.0"))
}
val foo by tasks.registering(JavaExec::class) {
classpath(bar)
mainClass.set(K2JVMCompiler::class.qualifiedName)
args("-script", file(".github/workflows/test.main.kts").absolutePath)
}
This results in the call:
java -cp \
.../kotlin-compiler-embeddable-1.7.0.jar;\
.../kotlin-main-kts-1.7.0.jar;\
.../kotlin-scripting-compiler-embeddable-1.7.0.jar;\
.../kotlin-scripting-compiler-impl-embeddable-1.7.0.jar;\
.../kotlin-scripting-jvm-1.7.0.jar;\
.../kotlin-script-runtime-1.7.0.jar;\
.../kotlin-reflect-1.7.0.jar;\
.../kotlin-scripting-common-1.7.0.jar;\
.../kotlin-stdlib-1.7.0.jar;\
.../kotlin-daemon-embeddable-1.7.0.jar;\
.../trove4j-1.0.20200330.jar;\
.../jna-5.6.0.jar;\
.../kotlin-stdlib-common-1.7.0.jar;\
.../annotations-13.0.jar \
org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -script .../.github/workflows/test.main.kts
Which results in
warning: unable to find kotlin-stdlib.jar in the Kotlin home directory. Pass either '-no-stdlib' to prevent adding it to the classpath, or the correct '-kotlin-home'
warning: unable to find kotlin-script-runtime.jar in the Kotlin home directory. Pass either '-no-stdlib' to prevent adding it to the classpath, or the correct '-kotlin-home'
warning: unable to find kotlin-reflect.jar in the Kotlin home directory. Pass either '-no-reflect' or '-no-stdlib' to prevent adding it to the classpath, or the correct '-kotlin-home'
error: no script runtime was found in the classpath: class 'kotlin.script.templates.standard.ScriptTemplateWithArgs' not found. Please add kotlin-script-runtime.jar to the module dependencies. (test.main.kts:3:1)
and then a whole bunch of unresolved reference errors.
Do you have any idea what is wrong?
All four mentioned jars are on the classpath.
If I add the suggested options, the warnings go away, but the errors remain.Vampire
06/19/2022, 9:58 PMval compilerClasspath by configurations.creating {
isCanBeConsumed = false
}
val scriptClasspath by configurations.creating {
isCanBeConsumed = false
}
dependencies {
compilerClasspath(kotlin("compiler-embeddable", "1.7.0"))
compilerClasspath(kotlin("scripting-compiler-embeddable", "1.7.0"))
scriptClasspath(kotlin("main-kts", "1.7.0"))
}
val foo by tasks.registering(JavaExec::class) {
classpath(compilerClasspath)
mainClass.set(K2JVMCompiler::class.qualifiedName)
args("-no-stdlib", "-no-reflect")
args("-classpath", scriptClasspath.asPath)
args("-script", file(".github/workflows/test.main.kts").absolutePath)
}
Vampire
06/19/2022, 9:59 PM.github\workflows\test.main.kts: error: failed to access class org.jetbrains.kotlin.com.google.common.base.Platform from class org.jetbrains.kotlin.com.google.common.base.Ticker$1 (org.jetbrains.kotlin.com.google.common.base.Platform is in unnamed module of loader 'app'; org.jetbrains.kotlin.com.google.common.base.Ticker$1 is in unnamed module of loader java.net.URLClassLoader @5cff6d1d)
😕Vampire
06/19/2022, 10:11 PMVampire
06/19/2022, 10:11 PMilya.chernikov
06/20/2022, 7:39 AM--illegal-access=permit
to the JavaExec
params.Vampire
06/22/2022, 8:56 PMjavaLauncher.set(javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(8)) })
and I'm still getting
.github\workflows\test.main.kts: error: tried to access class org.jetbrains.kotlin.com.google.common.base.Platform from class org.jetbrains.kotlin.com.google.common.base.Ticker$1
Vampire
06/22/2022, 9:00 PMVampire
06/22/2022, 9:03 PMjava.lang.IllegalAccessError: tried to access class org.jetbrains.kotlin.com.google.common.base.Platform from class org.jetbrains.kotlin.com.google.common.base.Ticker$1
at org.jetbrains.kotlin.com.google.common.base.Ticker$1.read(Ticker.java:55)
at org.jetbrains.kotlin.com.google.common.base.Stopwatch.start(Stopwatch.java:148)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3441)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2193)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2152)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2042)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache.get(LocalCache.java:3850)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3874)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4799)
at org.jetbrains.kotlin.com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4805)
at org.jetbrains.kotlin.com.google.inject.internal.Annotations$AnnotationChecker.hasAnnotations(Annotations.java:274)
at org.jetbrains.kotlin.com.google.inject.internal.Annotations.isBindingAnnotation(Annotations.java:340)
at org.jetbrains.kotlin.com.google.inject.Key.ensureIsBindingAnnotation(Key.java:349)
at org.jetbrains.kotlin.com.google.inject.Key.strategyFor(Key.java:336)
at org.jetbrains.kotlin.com.google.inject.Key.get(Key.java:219)
at org.jetbrains.kotlin.org.eclipse.sisu.wire.ParameterKeys.<clinit>(ParameterKeys.java:28)
at org.jetbrains.kotlin.org.codehaus.plexus.DefaultPlexusContainer$ContainerModule.configure(DefaultPlexusContainer.java:832)
at org.jetbrains.kotlin.com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)
at org.jetbrains.kotlin.com.google.inject.spi.Elements.getElements(Elements.java:103)
at org.jetbrains.kotlin.com.google.inject.spi.Elements.getElements(Elements.java:96)
at org.jetbrains.kotlin.org.eclipse.sisu.wire.MergedModule.configure(MergedModule.java:53)
at org.jetbrains.kotlin.com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)
at org.jetbrains.kotlin.com.google.inject.spi.Elements.getElements(Elements.java:103)
at org.jetbrains.kotlin.com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:137)
at org.jetbrains.kotlin.com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at org.jetbrains.kotlin.com.google.inject.Guice.createInjector(Guice.java:87)
at org.jetbrains.kotlin.com.google.inject.Guice.createInjector(Guice.java:69)
at org.jetbrains.kotlin.com.google.inject.Guice.createInjector(Guice.java:59)
at org.jetbrains.kotlin.org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:481)
at org.jetbrains.kotlin.org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:206)
at org.jetbrains.kotlin.org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:168)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession$repositorySystem$2.invoke(aether.kt:105)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession$repositorySystem$2.invoke(aether.kt:90)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession.getRepositorySystem(aether.kt:90)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession.access$getRepositorySystem(aether.kt:47)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession$resolveDependencies$1.invoke(aether.kt:141)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession$resolveDependencies$1.invoke(aether.kt:136)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession.fetch(aether.kt:192)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession.resolveDependencies(aether.kt:136)
at kotlin.script.experimental.dependencies.maven.impl.AetherResolveSession.resolve(aether.kt:131)
at kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver.resolve(MavenDependenciesResolver.kt:69)
at kotlin.script.experimental.dependencies.CompoundDependenciesResolver.resolve(CompoundDependenciesResolver.kt:68)
at kotlin.script.experimental.dependencies.AnnotationsKt.resolveFromScriptSourceAnnotations(annotations.kt:70)
at org.jetbrains.kotlin.mainKts.MainKtsConfigurator$processAnnotations$resolveResult$1.invokeSuspend(scriptDef.kt:201)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
at kotlin.script.experimental.impl.RunSuspendKt.internalScriptingRunSuspend(runSuspend.kt:19)
at org.jetbrains.kotlin.mainKts.MainKtsConfigurator.processAnnotations(scriptDef.kt:200)
at org.jetbrains.kotlin.mainKts.MainKtsConfigurator.invoke(scriptDef.kt:153)
at org.jetbrains.kotlin.mainKts.MainKtsConfigurator.invoke(scriptDef.kt:149)
at kotlin.script.experimental.api.ScriptCompilationKt.refineOnAnnotations(scriptCompilation.kt:295)
at org.jetbrains.kotlin.scripting.resolve.RefineCompilationConfigurationKt.refineScriptCompilationConfiguration(refineCompilationConfiguration.kt:236)
at org.jetbrains.kotlin.scripting.compiler.plugin.definitions.CliScriptDependenciesProvider.calculateRefinedConfiguration(CliScriptDependenciesProvider.kt:46)
at org.jetbrains.kotlin.scripting.compiler.plugin.definitions.CliScriptDependenciesProvider.getScriptConfigurationResult(CliScriptDependenciesProvider.kt:34)
at org.jetbrains.kotlin.scripting.compiler.plugin.dependencies.ScriptsCompilationDependenciesKt.collectScriptsCompilationDependencies(ScriptsCompilationDependencies.kt:49)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.CompilationContextKt.collectRefinedSourcesAndUpdateEnvironment(compilationContext.kt:302)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.ScriptJvmCompilerImplsKt.compileImpl(ScriptJvmCompilerImpls.kt:123)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.ScriptJvmCompilerImplsKt.access$compileImpl(ScriptJvmCompilerImpls.kt:1)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.ScriptJvmCompilerFromEnvironment$compile$1$1.invoke(ScriptJvmCompilerImpls.kt:78)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.ScriptJvmCompilerFromEnvironment$compile$1$1.invoke(ScriptJvmCompilerImpls.kt:67)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.ScriptJvmCompilerImplsKt.withScriptCompilationCache(ScriptJvmCompilerImpls.kt:99)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.ScriptJvmCompilerImplsKt.access$withScriptCompilationCache(ScriptJvmCompilerImpls.kt:1)
at org.jetbrains.kotlin.scripting.compiler.plugin.impl.ScriptJvmCompilerFromEnvironment.compile(ScriptJvmCompilerImpls.kt:67)
at org.jetbrains.kotlin.scripting.compiler.plugin.AbstractScriptEvaluationExtension$doEval$1.invokeSuspend(AbstractScriptEvaluationExtension.kt:135)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
at kotlin.script.experimental.impl.RunSuspendKt.internalScriptingRunSuspend(runSuspend.kt:19)
at org.jetbrains.kotlin.scripting.compiler.plugin.AbstractScriptEvaluationExtension.doEval(AbstractScriptEvaluationExtension.kt:134)
at org.jetbrains.kotlin.scripting.compiler.plugin.AbstractScriptEvaluationExtension.eval(AbstractScriptEvaluationExtension.kt:121)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:109)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:94)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:79)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:43)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:179)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:177)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:166)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:238)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
Vampire
06/22/2022, 9:15 PMVampire
06/22/2022, 9:25 PMVampire
06/22/2022, 9:28 PM@DependsOn
dependency from some local cache.
And there happens the error.Vampire
06/22/2022, 9:40 PMmain.kts.compiled.cache
and try to rerun the only working version it now also fails with the same error, so that assumption was correctPaul Woitaschek
06/23/2022, 10:28 AMVampire
06/23/2022, 11:55 AMVampire
06/23/2022, 8:02 PMVampire
06/24/2022, 11:31 AMilya.chernikov
06/24/2022, 12:20 PMmain-kts
jar.ilya.chernikov
06/24/2022, 12:23 PMAny idea where that compiler / resolver stores state on disk?There is only two caches involved here. One is
main.kts.compiled.cache
, that seems you're aware of. It stores compiled script and do not perform artefact resolving, if script is not changed (or classloading error happened on attempt to run it).
And the second is the regular maven's local repo, typically '~/.m2`, since main-kts
uses maven/aether resolver under the hood.Vampire
06/24/2022, 1:34 PMmain.kts.compiled.cache
I found out.
Actually I would wonder if the ~/.m2
is releated, because that was always present, as I used a custom snapshot build of the dependency I need right from the start and the one time the compile worked it was also with that, so at least ~/.m2
was present and had content.Vampire
06/24/2022, 1:38 PM.m2
to .m2.bak
and it still failsilya.chernikov
06/24/2022, 1:39 PMmain-kts
intransitive:
scriptClasspath(kotlin("main-kts", "1.7.0")) { isTransitive = false }
ilya.chernikov
06/24/2022, 1:41 PMilya.chernikov
06/24/2022, 1:43 PMVampire
06/24/2022, 1:45 PMkotlin(...)
does not work with additional configuration like isTransitive = false
ilya.chernikov
06/24/2022, 1:47 PMkotlin
helpertVampire
06/24/2022, 1:48 PMAny
as argument that takes the configuration closureVampire
06/24/2022, 1:50 PMscriptClasspath("org.jetbrains.kotlin:kotlin-main-kts:1.7.0") { isTransitive = false }
Vampire
06/24/2022, 1:50 PMilya.chernikov
06/24/2022, 1:52 PMVampire
06/24/2022, 1:58 PMVampire
06/24/2022, 2:00 PMCould you try, for the sake of experiment, to just manually put the path to main-kts to the classpath, as you'd do if you'd run the cli compiler?
And/or print/lookup in the log the actual cli command that JavaExec runs?This is what got run with the
isTransitive = true
added, that is already what you mean, isn't it?
C:\Program Files\AdoptOpenJDK\jdk-11.0.11.9-hotspot\bin\java.exe
-Dfile.encoding=windows-1252
-Duser.country=DE
-Duser.language=de
-Duser.variant
-cp D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-compiler-embeddable\1.7.0\4d09852239f61842072b40b524882fa3caaed371\kotlin-compiler-embeddable-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-compiler-embeddable\1.7.0\69924a0f52055776049f96ee09d875233e253529\kotlin-scripting-compiler-embeddable-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.7.0\e660b0079fdaf744dc9cc7f6f3aa3c761ec839b0\kotlin-reflect-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-compiler-impl-embeddable\1.7.0\69ebbb984c0e9c7a9ca8a4ed0a87b36f1c793ed8\kotlin-scripting-compiler-impl-embeddable-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-jvm\1.7.0\d03ca0d4594387836eecc7c67cec679f34172b36\kotlin-scripting-jvm-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-scripting-common\1.7.0\1a19885731b40f0340c90c3edd70c157be90ac8c\kotlin-scripting-common-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.7.0\a5f42c684ad9003160ef0d0f693ecf0ba7b13549\kotlin-stdlib-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-script-runtime\1.7.0\3acea1d447587e61bc3e1b3ed6227d9e9ed4ddf1\kotlin-script-runtime-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-daemon-embeddable\1.7.0\fd56798de80825c673ac93808284c5198ffa2b50\kotlin-daemon-embeddable-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.intellij.deps\trove4j\1.0.20200330\3afb14d5f9ceb459d724e907a21145e8ff394f02\trove4j-1.0.20200330.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\net.java.dev.jna\jna\5.6.0\330f2244e9030119ab3030fc3fededc86713d9cc\jna-5.6.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.7.0\51736992f422993a1e741051bdf3c12801bc1ca1\kotlin-stdlib-common-1.7.0.jar;
D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar
org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
-no-stdlib
-no-reflect
-classpath D:\Dateien\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-main-kts\1.7.0\c18ae34753397e8d980859a4e43b63d067cf30ca\kotlin-main-kts-1.7.0.jar
-script D:\Sourcecode\other\setup-wsl\.github\workflows\test.main.kts
Vampire
06/24/2022, 2:02 PMTicker
is used from main-kts
artifact while the Platform
is used from the compiler and each from different class loaders.ilya.chernikov
06/24/2022, 2:28 PMilya.chernikov
06/24/2022, 2:31 PMVampire
06/24/2022, 3:23 PMerror: no script runtime was found in the classpath: class 'kotlin.script.templates.standard.ScriptTemplateWithArgs' not found. Please add kotlin-script-runtime.jar to the module dependencies. (test.main.kts:5:1)
and then a whole lot of unresolved reference errors.
If I add it to both, it indeed works, probably because then in the script class path the script runtime is present, but the Ticker
is used from the same class loader as `Platform`n and thus does not show the problem.
Additionally, with this it seems to work:
dependencies {
compilerClasspath(kotlin("compiler", "1.7.0"))
compilerClasspath(kotlin("scripting-compiler", "1.7.0"))
scriptClasspath(kotlin("main-kts", "1.7.0"))
}
with this too:
dependencies {
compilerClasspath(kotlin("compiler", "1.7.0"))
compilerClasspath(kotlin("scripting-compiler", "1.7.0"))
scriptClasspath("org.jetbrains.kotlin:kotlin-main-kts:1.7.0") { isTransitive = false }
}
and this too, which mitigates the problem that there is no overload with configuration function for `Any`:
dependencies {
compilerClasspath(kotlin("compiler", "1.7.0"))
compilerClasspath(kotlin("scripting-compiler", "1.7.0"))
add(scriptClasspath.name, kotlin("main-kts", "1.7.0"), closureOf<ExternalModuleDependency> { isTransitive = false } as Closure<Any>)
}
Why did you actually suggest to use the embedded compiler instead of the compiler?ilya.chernikov
06/24/2022, 3:46 PMilya.chernikov
06/24/2022, 3:51 PMWhy did you actually suggest to use the embedded compiler instead of the compiler?I think I suggested a few times above to try it with regular compiler. Although it would work only with intransitive deps, I guess. The embeddable compiler supposed to be the default for all cases, but seems we're getting a conflict in this particular scenario, which we need to fix. I believe it works with regular compiler since now the
Platform
class is different - the one used in the main-kts is relocated, while the one in the compiler itself is not, so no conflict anymore.ilya.chernikov
06/24/2022, 3:53 PMilya.chernikov
06/24/2022, 3:55 PMVampire
06/24/2022, 3:56 PMI think I suggested a few times above to try it with regular compiler.Yes, but you suggested with embedded first and had other suggestions to try and I am also doing my dayjob while trying these things alongside. 😉
Although it would work only with intransitive deps, I guess.No, as written above, it worked with transitive
main-kts
.
I believe it works with regular compiler since now theAh, I see, makes sense.class is differentPlatform
(I suppose that overload with Any is somewhat fishy too, but is a separate problem, and maybe more on the Gradle side).I think so too
And thanks again for bringing it up, seems that we need to do something about it.Always a pleasure to complain 😄
Vampire
06/24/2022, 3:56 PM