A good approach for dynamically loading and recompiling 3rd-party projects

I’m trying to make an animation framework in Kotlin, similar to Motion Canvas, but using Kotlin coroutines instead of JS generator functions. It runs on the JVM, since it uses Compose Desktop for all the state tracking and rendering. I’m trying to decide how I want to implement an editor for it that lets you preview the animation, step frames forward and backward, and move timeline markers, like the one MC has.

My current thought is that projects are a complete Gradle setup. The project would have a compileOnly dependency on my tool, which enables full code analysis (which is why I’m avoiding JSR223; it’s supposed to be possible but I still haven’t figured it out). A special Gradle task outputs a JAR and signals (through IPC or otherwise, maybe even just a filesystem watcher) to the editor process to reload the JAR file, which is then loaded with a child classloader, then has its entry point invoked, something like this:

val urlClassLoader = URLClassLoader(
    arrayOf(URI.create("/path/to/jar").toURL())
)
val clazz = urlClassLoader.loadClass("communicated.through.IPC.or.config.somehow.EntryPointClass")
val inst = clazz.getDeclaredConstructor().newInstance() as SomeSupertypeOfThat
inst.runAnimation()

My main concerns are that I have actually no idea how to do most of this, and also that I don’t know if there’s a better/easier/faster way to do it.