Wyatt Kennedy
07/23/2023, 4:02 AMkotlin("jvm") version "1.9.0"/kotlin-stdlib-common-1.9.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.5.1"1.5.10"kotlinx-coroutines-coreUnable to construct script definition: Unable to load base class kotlin.script.experimental.api.KotlinType@1f76d9c0@KotlinScriptShaderDefval configuration = createJvmCompilationConfigurationFromTemplate<ShaderDef> {  }
val results = BasicJvmScriptingHost().eval(extension.file.get().toScriptSource(), configuration, null)
results.reports.forEach {
    if (it.severity > ScriptDiagnostic.Severity.DEBUG) {
        println(" : ${it.message}" + if (it.exception == null) "" else ": ${it.exception}")
    }
}Wyatt Kennedy
07/23/2023, 4:08 AMWyatt Kennedy
07/23/2023, 4:15 AMjvm {
    dependenciesFromCurrentContext(wholeClasspath = true)
}mbonnin
07/23/2023, 9:40 AMmbonnin
07/23/2023, 9:40 AMmbonnin
07/23/2023, 9:42 AMWyatt Kennedy
07/23/2023, 6:09 PMmbonnin
07/23/2023, 6:11 PMmbonnin
07/23/2023, 6:11 PMWyatt Kennedy
07/23/2023, 6:23 PMUnable to load base class kotlin.script.experimental.api.KotlinType@1f776f8borg.jetbrains.kotlin:kotlin-scripting-jvmmbonnin
07/23/2023, 6:24 PManother projectIs that other project also using 8.2?
mbonnin
07/23/2023, 6:24 PMIs there something funky about plugin classpathsThere so many funky things with Gradle classpaths I don't even know where to begin
mbonnin
07/23/2023, 6:28 PMmbonnin
07/23/2023, 6:30 PM// build-logic/build.gradle.kts
dependencies {
  implementation("com.example:com.example-gradle-plugin:$version")
  implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")
  // etc...
}mbonnin
07/23/2023, 6:30 PMIs there anything more to this error ? (stacktrace or so?)Unable to load base class kotlin.script.experimental.api.KotlinType@1f776f8b
mbonnin
07/23/2023, 6:31 PMNoSuchMethodClassNotFoundWyatt Kennedy
07/23/2023, 6:31 PMmbonnin
07/23/2023, 6:32 PM./gradlew --stopWyatt Kennedy
07/23/2023, 6:37 PMCaused by: java.lang.ClassNotFoundException: org.ksentiment.ShaderDefat kotlin.script.experimental.jvm.JvmGetScriptingClass.invoke(jvmScriptingHostConfiguration.kt:117)mbonnin
07/23/2023, 6:38 PMWyatt Kennedy
07/23/2023, 6:38 PM_implementation_("org.ksentiment:shader-script-definition")mbonnin
07/23/2023, 6:39 PMmbonnin
07/23/2023, 6:40 PMincludueBuild("../shader-script-definition)mbonnin
07/23/2023, 6:41 PMconsumer buildWyatt Kennedy
07/23/2023, 6:42 PMinclude("client")
includeBuild("shader-script-definition")
pluginManagement {
    includebuild("shader-plugin")
}Wyatt Kennedy
07/23/2023, 6:44 PMplugins {
    kotlin("plugin.serialization") version "1.6.10"
    kotlin("multiplatform")
    id("org.ksentiment.shader-plugin") version "1.0-SNAPSHOT"
    `maven-publish`
}mbonnin
07/23/2023, 6:44 PMWyatt Kennedy
07/23/2023, 6:44 PMmbonnin
07/23/2023, 6:45 PM"1.0-SNAPSHOT"mbonnin
07/23/2023, 6:45 PMinclude("client")
pluginManagement {
    includeBuild("shader-script-definition")
    includebuild("shader-plugin")
}mbonnin
07/23/2023, 6:46 PMorg.ksentiment.ShaderDefshader-script-definitionmbonnin
07/23/2023, 6:46 PMmbonnin
07/23/2023, 6:46 PMWyatt Kennedy
07/23/2023, 6:49 PMWyatt Kennedy
07/23/2023, 8:05 PMmbonnin
07/23/2023, 8:13 PMmbonnin
07/23/2023, 8:13 PMTask clientbuildEnvironment------------------------------------------------------------ Project ':client' ------------------------------------------------------------ classpath +--- project :plugin | \--- github.fatalcatharsis:script-definition -> project :script-definition | +--- org.jetbrains.kotlinkotlin stdlib jdk81.8.20 (*) | +--- org.jetbrains.kotlinkotlin scripting common1.8.20 (*)
mbonnin
07/23/2023, 8:13 PMbuildEnvironmentmbonnin
07/23/2023, 8:14 PMmbonnin
07/23/2023, 8:22 PMmbonnin
07/23/2023, 8:29 PMapply()val clazz = Class.forName("github.fatalcatharsis.ScriptDefinition")
        println("clasName '${clazz}'")mbonnin
07/23/2023, 8:58 PMmbonnin
07/23/2023, 9:10 PMthis.javaClass.classLoader = {VisitableURLClassLoader$InstrumentingVisitableURLClassLoader@13732} "InstrumentingVisitableURLClassLoader(ClassLoaderScopeIdentifier.Id{coreAndPlugins:settings[:]:buildSrc[:]:root-project[:]:project-client(export)})"
ScriptCompilationConfiguration::class.java.classLoader = {VisitableURLClassLoader@13733} "VisitableURLClassLoader(ant-and-gradle-loader)"Wyatt Kennedy
07/23/2023, 9:10 PMmbonnin
07/23/2023, 9:11 PMmbonnin
07/23/2023, 9:11 PMScriptDefinitionmbonnin
07/23/2023, 9:12 PMScriptDefinitionmbonnin
07/23/2023, 9:12 PMmbonnin
07/23/2023, 9:13 PMWyatt Kennedy
07/23/2023, 9:17 PMmbonnin
07/23/2023, 9:19 PMWe're well outside my realm of understanding100% same here, sorry 😅
mbonnin
07/23/2023, 9:20 PMmbonnin
07/23/2023, 9:24 PMmbonnin
07/23/2023, 9:24 PMmbonnin
07/23/2023, 9:25 PMmbonnin
07/23/2023, 9:25 PMkotlin-scripting-jvmbuild.gradle.ktsmbonnin
07/23/2023, 9:26 PMkotlin-stdlibmbonnin
07/23/2023, 9:28 PMkotlin-scripting-jvmScriptCompilationConfigurationScriptDefinitionmbonnin
07/23/2023, 9:28 PMScriptDefinitionmbonnin
07/23/2023, 9:29 PMmbonnin
07/23/2023, 9:30 PMWyatt Kennedy
07/23/2023, 9:38 PM> Could not resolve all files for configuration ':client:classpath'.
   > Could not find github.fatalcatharsis:script-definition:.
     Required by:
         project :client > github.fatalcatharsis.test-plugin:github.fatalcatharsis.test-plugin.gradle.plugin:1.0-SNAPSHOT > github.fatalcatharsis:plugin:1.0-SNAPSHOTmbonnin
07/23/2023, 9:43 PMmbonnin
07/23/2023, 9:44 PMmbonnin
07/23/2023, 9:45 PMkotlin-scripting-jvmWyatt Kennedy
07/23/2023, 9:47 PMmbonnin
07/23/2023, 9:47 PMmbonnin
07/23/2023, 9:48 PM$ ./gradlew :client:test-kts-script 
> Task :client:test-kts-script
 : Using new faster version of JAR FS: it should make your build faster, but the new implementation is experimental
 : /Users/mbonnin/git/gradle-plugin-kotlin-script-test-mre/client/example.test.kts (No such file or directory): java.io.FileNotFoundException: /Users/mbonnin/git/gradle-plugin-kotlin-script-test-mre/client/example.test.kts (No such file or directory)
BUILD SUCCESSFUL in 1sWyatt Kennedy
07/23/2023, 9:57 PMmbonnin
07/23/2023, 10:01 PMdo I just have to specify these classes I need in the script context because of me using it in a gradle plugin for some reason?Yes. I'm not 100% certain of the reason but my mental model is along the lines of this: by default, the Kotlin scripting host uses the classloader of
ScriptCompilationConfigurationkotlin-scripting-jvm-host-1.8.20.jarkotlin-scripting-jvm-host-1.8.20.jarbuild.gradle.ktsScriptDefinitionmbonnin
07/23/2023, 10:02 PMScriptDefinition::class.java.classLoaderScriptDefinitionmbonnin
07/23/2023, 10:03 PMWyatt Kennedy
07/23/2023, 10:05 PM